Skip to content

Commit

Permalink
DM-9249 Change FlagHandler to remove the enum of flag types
Browse files Browse the repository at this point in the history
The enum which formerly numbered the available failure flags is replaced with
a set of static FlagDefinitions: (e.g., static FlagDefinition const FAILURE;
for the general flag). The position of the flag in the FlagHandler list is
now the number value of the FlagDefinition (e.g., FAILURE.number).

A new class FlagDefinitionList is introduced to specify the
FlagDefinitions used to initialize the FlagHandler.
Add flags to the FlagDefinitionList using the methods
addFailureFlag() and add(name, doc). When done, use the FlagHandler
initializer addFields(schema, name, flagDefinitionList).

An optional exclusion list exclDefs is provided if some members of
the algorithms FlagDefinitionList are not desired.
The _flagHandler keeps the same numbering of flags whether or not
a flag is excluded -- the FlagDefinition.number is fixed.

It is now optional whether a General Failure flag is defined for the
flagHandler.

Remove the FlagHandler::FAILURE which assumes FAILURE is position 0.
  • Loading branch information
pgee2000 committed Mar 3, 2017
1 parent 06625e2 commit 4c2df6d
Show file tree
Hide file tree
Showing 30 changed files with 685 additions and 474 deletions.
26 changes: 14 additions & 12 deletions include/lsst/meas/base/ApertureFlux.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,13 @@ struct ApertureFluxResult;
class ApertureFluxAlgorithm : public SimpleAlgorithm {
public:

/// @copydoc PsfFluxAlgorithm::FlagBits
enum FlagBits {
FAILURE=0,
APERTURE_TRUNCATED,
SINC_COEFFS_TRUNCATED,
N_FLAGS
};
// Structures and routines to manage flaghandler
static FlagDefinitionList const & getFlagDefinitions();
static unsigned int const N_FLAGS = 3;
static FlagDefinition const FAILURE;
static FlagDefinition const APERTURE_TRUNCATED;
static FlagDefinition const SINC_COEFFS_TRUNCATED;

/// Typedef to the control object associated with this algorithm, defined above.
typedef ApertureFluxControl Control;

/// Result object returned by static methods.
Expand Down Expand Up @@ -222,7 +220,6 @@ class ApertureFluxAlgorithm : public SimpleAlgorithm {
/**
* Return the flag definitions which apply to aperture flux measurements.
*/
static std::array<FlagDefinition,ApertureFluxAlgorithm::N_FLAGS> const & getFlagDefinitions();

protected:

Expand Down Expand Up @@ -254,13 +251,18 @@ class ApertureFluxAlgorithm : public SimpleAlgorithm {
struct ApertureFluxResult : public FluxResult {

/// Return the flag value associated with the given bit
bool getFlag(ApertureFluxAlgorithm::FlagBits bit) const { return _flags[bit]; }
bool getFlag(unsigned int index) const { return _flags[index]; }

/// Return the flag value associated with the given flag name
bool getFlag(std::string name) const {
return _flags[ApertureFluxAlgorithm::getFlagDefinitions().getDefinition(name).number];
}

/// Set the flag value associated with the given bit
void setFlag(ApertureFluxAlgorithm::FlagBits bit, bool value=true) { _flags[bit] = value; }
void setFlag(unsigned int index, bool value=true) { _flags[index] = value; }

/// Clear (i.e. set to false) the flag associated with the given bit
void unsetFlag(ApertureFluxAlgorithm::FlagBits bit) { _flags[bit] = false; }
void unsetFlag(unsigned int index) { _flags[index] = false; }

private:
std::bitset<ApertureFluxAlgorithm::N_FLAGS> _flags;
Expand Down
12 changes: 6 additions & 6 deletions include/lsst/meas/base/Blendedness.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ class BlendednessControl {
class BlendednessAlgorithm : public SimpleAlgorithm {
public:

enum {
FAILURE=FlagHandler::FAILURE,
NO_CENTROID,
NO_SHAPE,
N_FLAGS
};
// Structures and routines to manage flaghandler
static FlagDefinitionList const & getFlagDefinitions();
static FlagDefinition const FAILURE;
static FlagDefinition const NO_CENTROID;
static FlagDefinition const NO_SHAPE;

typedef BlendednessControl Control;

BlendednessAlgorithm(Control const & ctrl, std::string const & name, afw::table::Schema & schema);
Expand Down

0 comments on commit 4c2df6d

Please sign in to comment.