32 #include "boost/format.hpp" 33 #include "boost/algorithm/string/trim.hpp" 45 FilterProperty::PropertyMap* FilterProperty::_propertyMap = NULL;
48 : _name(name), _lambdaEff(NAN), _lambdaMin(NAN), _lambdaMax(NAN) {
49 if (prop.
exists(
"lambdaEff")) {
52 if (prop.
exists(
"lambdaMin")) {
55 if (prop.
exists(
"lambdaMax")) {
61 void FilterProperty::_insert(
bool force) {
66 PropertyMap::iterator keyVal = _propertyMap->
find(
getName());
68 if (keyVal != _propertyMap->
end()) {
69 if (keyVal->second == *
this) {
76 _propertyMap->
erase(keyVal);
83 return (_lambdaEff == rhs._lambdaEff);
88 void FilterProperty::_initRegistry() {
101 PropertyMap::iterator keyVal = _propertyMap->
find(name);
103 if (keyVal == _propertyMap->
end()) {
107 return keyVal->second;
119 if (metadata->exists(key)) {
120 std::string filterName = boost::algorithm::trim_right_copy(metadata->getAsString(key));
121 _id = _lookup(filterName, force);
131 if (metadata->exists(key)) {
132 metadata->remove(key);
144 std::string const& canonicalName = getCanonicalName();
145 for (AliasMap::iterator ptr = _aliasMap->begin(),
end = _aliasMap->end(); ptr !=
end; ++ptr) {
146 if (ptr->second == canonicalName) {
161 for (NameMap::const_iterator ptr = _nameMap->begin(),
end = _nameMap->end(); ptr !=
end; ++ptr) {
162 if (ptr->first != unknownFilter) {
175 void Filter::_initRegistry() {
201 NameMap::iterator keyVal = _nameMap->
find(name);
203 if (keyVal != _nameMap->end()) {
204 int oid = keyVal->second;
206 if (
id == oid ||
id == AUTO) {
213 _nameMap->erase(keyVal);
234 NameMap::iterator keyVal = _nameMap->find(oldName);
235 if (keyVal == _nameMap->end()) {
238 int const id = keyVal->second;
241 AliasMap::iterator aliasKeyVal = _aliasMap->find(newName);
242 if (aliasKeyVal != _aliasMap->end()) {
243 if (aliasKeyVal->second == oldName) {
250 _aliasMap->erase(aliasKeyVal);
263 NameMap::iterator keyVal = _nameMap->find(name);
265 if (keyVal == _nameMap->end()) {
266 AliasMap::iterator aliasKeyVal = _aliasMap->find(name);
267 if (aliasKeyVal != _aliasMap->end()) {
268 return _lookup(aliasKeyVal->second);
278 return keyVal->second;
286 IdMap::iterator keyVal = _idMap->find(
id);
288 if (keyVal == _idMap->end()) {
292 return keyVal->second;
298 int const id = _lookup(_name,
true);
double getAsDouble(std::string const &name) const
bool operator==(Filter const &rhs) const noexcept
Are two filters identical?
std::size_t hash_value() const noexcept
Return a hash of this object.
std::string const & getName() const noexcept
Return a filter's name.
int stripFilterKeywords(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Remove Filter-related keywords from the metadata.
Rotation angle is unknown.
static FilterProperty const & lookup(std::string const &name)
Lookup the properties of a filter "name".
A base class for image defects.
bool operator==(FilterProperty const &rhs) const noexcept
Return true iff two FilterProperties are identical.
static int define(FilterProperty const &filterProperty, int id=AUTO, bool force=false)
Define a filter name to have the specified id.
std::vector< std::string > getAliases() const
Return all aliases by which this filter is known.
bool exists(std::string const &name) const
static int defineAlias(std::string const &oldName, std::string const &newName, bool force=false)
Define an alias for a filter.
Holds an integer identifier for an LSST filter.
#define LSST_EXCEPT(type,...)
Filter(std::string const &name, bool const force=false)
Creates a Filter with the given name.
FilterProperty const & getFilterProperty() const
Return a Filter's FilterProperty.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
Describe the properties of a Filter (e.g.
FilterProperty(std::string const &name, double lambdaEff, double lambdaMin=NAN, double lambdaMax=NAN, bool force=false)
static std::vector< std::string > getNames()
Return a list of known filters.
std::size_t hash_value() const noexcept
Return a hash of this object.