23#ifndef LSST_MEAS_BASE_FlagHandler_h_INCLUDED
24#define LSST_MEAS_BASE_FlagHandler_h_INCLUDED
72 add(iter->name, iter->doc);
89 if (_vector[i].
name ==
name)
return _vector[i];
102 if (_vector[i].
name ==
name)
return true;
118 _vector.push_back(flagDef);
119 return _vector.back();
223 for (
unsigned int i = 0; i < _vector.
size(); i++) {
224 if (_vector[i].first == flagName && _vector[i].second.isValid()) {
234 if (i < _vector.
size() && _vector[i].second.isValid()) {
235 return _vector[i].first;
243 if (i < _vector.
size() && _vector[i].second.isValid()) {
244 return record.
get(_vector[i].second);
253 if (_vector[i].first == flagName && _vector[i].second.isValid()) {
254 return record.
get(_vector[i].second);
263 if (i < _vector.
size() && _vector[i].second.isValid()) {
264 record.
set(_vector[i].second, value);
274 if (_vector[i].first == flagName && _vector[i].second.isValid()) {
275 record.
set(_vector[i].second, value);
table::Key< std::string > name
Base class for all records.
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
Defines the fields and offsets for a table.
A proxy type for name lookups in a Schema.
Exception to be thrown when a measurement algorithm experiences a fatal error.
vector-type utility class to build a collection of FlagDefinitions
FlagDefinition add(std::string const &name, std::string const &doc)
Add a new FlagDefinition to this list.
FlagDefinitionList()
initialize a FlagDefinition list with no entries.
FlagDefinition getDefinition(std::size_t index) const
get a reference to the FlagDefinition with specified index.
FlagDefinition getDefinition(std::string const &name) const
get a reference to the FlagDefinition with specified name.
static FlagDefinitionList const & getEmptyList()
std::size_t size() const
return the current size (number of defined elements) of the collection
FlagDefinition addFailureFlag(std::string const &doc="General Failure Flag")
Add a Flag Defintion to act as a "General" failure flag This flag will be set if a Measurement error ...
FlagDefinitionList(std::initializer_list< FlagDefinition > const &list)
initialize a FlagDefinition list from initializer_list.
FlagDefinition operator[](std::size_t index) const
get a reference to the FlagDefinition with specified array index
bool hasDefinition(std::string const &name) const
See if there is a FlagDefinition with specified name.
Utility class for handling flag fields that indicate the failure modes of an algorithm.
std::string getFlagName(std::size_t i) const
Return the value of the flag name corresponding to the given flag index.
std::size_t failureFlagNumber
bool getValue(afw::table::BaseRecord const &record, std::string const &flagName) const
Return the value of the flag field with the given flag name.
std::size_t getFailureFlagNumber() const
Get the index of the General Failure flag, if one is defined.
void handleFailure(afw::table::BaseRecord &record, MeasurementError const *error=nullptr) const
Handle an expected or unexpected Exception thrown by a measurement algorithm.
FlagHandler()
Each error should have a corresponding static FlagDefinition object.
static FlagHandler addFields(afw::table::Schema &schema, std::string const &prefix, FlagDefinitionList const &flagDefs, FlagDefinitionList const &exclDefs=FlagDefinitionList::getEmptyList())
Add Flag fields to a schema, creating a FlagHandler object to manage them.
void setValue(afw::table::BaseRecord &record, std::string const &flagName, bool value) const
Set the flag field corresponding to the given flag name.
unsigned int getFlagNumber(std::string const &flagName) const
Return the index of a flag with the given flag name.
static std::string const & getFailureFlagName()
Define the universal name of the general failure flag.
void setValue(afw::table::BaseRecord &record, std::size_t i, bool value) const
Set the flag field corresponding to the given flag index.
bool getValue(afw::table::BaseRecord const &record, std::size_t i) const
Return the value of the flag field corresponding to the given flag index.
Exception to be thrown when a measurement algorithm experiences a known failure mode.
daf::base::PropertyList * list
Simple class used to define and document flags The name and doc constitute the identity of the FlagDe...
bool operator!=(FlagDefinition const &other) const
static constexpr std::size_t number_undefined
FlagDefinition(std::string const &name, std::string const &doc, std::size_t number=number_undefined)
bool operator==(FlagDefinition const &other) const