LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
LSSTDataManagementBasePackage
FlagHandler.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2014 LSST Corporation.
5  *
6  * This product includes software developed by the
7  * LSST Project (http://www.lsst.org/).
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the LSST License Statement and
20  * the GNU General Public License along with this program. If not,
21  * see <http://www.lsstcorp.org/LegalNotices/>.
22  */
23 
24 #ifndef LSST_MEAS_BASE_FlagHandler_h_INCLUDED
25 #define LSST_MEAS_BASE_FlagHandler_h_INCLUDED
26 
27 #include <vector>
28 
29 #include "lsst/afw/table/Schema.h"
32 
33 namespace lsst { namespace meas { namespace base {
34 
42 
44  }
45 
46  FlagDefinition(std::string _name, std::string _doc) {
47  name = _name;
48  doc = _doc;
49  }
50 
51  std::string name;
52  std::string doc;
53 };
54 
73 class FlagHandler {
74 public:
75 
93  enum { FAILURE=0 };
94 
106 
124  static FlagHandler addFields(
126  std::string const & prefix,
127  FlagDefinition const * begin,
128  FlagDefinition const * end
129  );
130 
144  static FlagHandler addFields(
146  std::string const & prefix,
147  std::vector<FlagDefinition> const * flagDefs
148  );
149 
163  FlagHandler(
164  afw::table::SubSchema const & s,
165  FlagDefinition const * begin,
166  FlagDefinition const * end
167  );
168 
172  FlagDefinition getDefinition(std::size_t i) const {
173  assert(_vector.size() > i); // Flag 'i' needs to be available
174  return _vector[i].first;
175  }
176 
180  bool getValue(afw::table::BaseRecord const & record, std::size_t i) const {
181  assert(_vector.size() > i); // Flag 'i' needs to be available
182  return record.get(_vector[i].second);
183  }
184 
188  void setValue(afw::table::BaseRecord & record, std::size_t i, bool value) const {
189  assert(_vector.size() > i); // Flag 'i' needs to be available
190  record.set(_vector[i].second, value);
191  }
192 
201  void handleFailure(afw::table::BaseRecord & record, MeasurementError const * error=NULL) const;
202 
203 private:
204 
205  typedef std::vector< std::pair<FlagDefinition, afw::table::Key<afw::table::Flag> > > Vector;
206 
208 };
209 
210 }}} // lsst::meas::base
211 
212 #endif // !LSST_MEAS_BASE_FlagHandler_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:44
bool getValue(afw::table::BaseRecord const &record, std::size_t i) const
Definition: FlagHandler.h:180
A proxy type for name lookups in a Schema.
Definition: Schema.h:326
FlagDefinition getDefinition(std::size_t i) const
Definition: FlagHandler.h:172
std::vector< std::pair< FlagDefinition, afw::table::Key< afw::table::Flag > > > Vector
Definition: FlagHandler.h:205
std::string const & _name
Definition: Mask.cc:678
afw::table::Schema schema
Definition: GaussianPsf.cc:41
Simple POD struct used to define and document flags.
Definition: FlagHandler.h:41
Exception to be thrown when a measurement algorithm experiences a known failure mode.
Definition: exceptions.h:48
void handleFailure(afw::table::BaseRecord &record, MeasurementError const *error=NULL) const
Definition: FlagHandler.cc:77
def error
Definition: log.py:103
Base class for all records.
Definition: BaseRecord.h:27
static FlagHandler addFields(afw::table::Schema &schema, std::string const &prefix, FlagDefinition const *begin, FlagDefinition const *end)
Definition: FlagHandler.cc:28
void setValue(afw::table::BaseRecord &record, std::size_t i, bool value) const
Definition: FlagHandler.h:188
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
Definition: BaseRecord.h:145
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
Definition: BaseRecord.h:132
FlagDefinition(std::string _name, std::string _doc)
Definition: FlagHandler.h:46