31 #include "boost/format.hpp" 32 #include "boost/algorithm/string/trim.hpp" 43 FilterProperty::PropertyMap* FilterProperty::_propertyMap = NULL;
46 :
_name(name), _lambdaEff(-1) {
47 if (prop.
exists(
"lambdaEff")) {
54 : _name(name), _lambdaEff(-1) {
55 if (pol.
exists(
"lambdaEff")) {
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);
84 void FilterProperty::_initRegistry() {
97 PropertyMap::iterator keyVal = _propertyMap->
find(name);
99 if (keyVal == _propertyMap->
end()) {
103 return keyVal->second;
115 if (metadata->exists(key)) {
116 std::string filterName = boost::algorithm::trim_right_copy(metadata->getAsString(key));
117 _id = _lookup(filterName, force);
127 if (metadata->exists(key)) {
128 metadata->remove(key);
140 std::string const& canonicalName = getCanonicalName();
141 for (AliasMap::iterator ptr = _aliasMap->begin(),
end = _aliasMap->end(); ptr !=
end; ++ptr) {
142 if (ptr->second == canonicalName) {
157 for (NameMap::const_iterator ptr = _nameMap->begin(),
end = _nameMap->end(); ptr !=
end; ++ptr) {
158 if (ptr->first != unknownFilter) {
169 void Filter::_initRegistry() {
195 NameMap::iterator keyVal = _nameMap->
find(name);
197 if (keyVal != _nameMap->end()) {
198 int oid = keyVal->second;
200 if (
id == oid ||
id == AUTO) {
207 _nameMap->erase(keyVal);
228 NameMap::iterator keyVal = _nameMap->find(oldName);
229 if (keyVal == _nameMap->end()) {
232 int const id = keyVal->second;
235 AliasMap::iterator aliasKeyVal = _aliasMap->find(newName);
236 if (aliasKeyVal != _aliasMap->end()) {
237 if (aliasKeyVal->second == oldName) {
244 _aliasMap->erase(aliasKeyVal);
257 NameMap::iterator keyVal = _nameMap->find(name);
259 if (keyVal == _nameMap->end()) {
260 AliasMap::iterator aliasKeyVal = _aliasMap->find(name);
261 if (aliasKeyVal != _aliasMap->end()) {
262 return _lookup(aliasKeyVal->second);
272 return keyVal->second;
280 IdMap::iterator keyVal = _idMap->find(
id);
282 if (keyVal == _idMap->end()) {
286 return keyVal->second;
292 int const id = _lookup(
_name,
true);
double getAsDouble(std::string const &name) const
bool operator==(FilterProperty const &rhs) const
Return true iff two FilterProperties are identical.
table::Key< std::string > name
std::string const & _name
bool operator==(Filter const &rhs) const
Are two filters identical?
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 exists(const std::string &name) const
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
std::string const & getName() const
Return a filter's name.
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.
double getDouble(const std::string &name) const
#define LSST_EXCEPT(type,...)
FilterProperty(std::string const &name, double lambdaEff, bool force=false)
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.
Describe the properties of a Filter (e.g.
static std::vector< std::string > getNames()
Return a list of known filters.