32 #include "boost/format.hpp" 
   33 #include "boost/algorithm/string/trim.hpp" 
   48 FilterProperty::PropertyMap* FilterProperty::_propertyMap = 
nullptr;
 
   51         : _name(
name), _lambdaEff(NAN), _lambdaMin(NAN), _lambdaMax(NAN) {
 
   52     if (prop.
exists(
"lambdaEff")) {
 
   55     if (prop.
exists(
"lambdaMin")) {
 
   58     if (prop.
exists(
"lambdaMax")) {
 
   64 void FilterProperty::_insert(
bool force) {
 
   69     PropertyMap::iterator keyVal = _propertyMap->find(
getName());
 
   71     if (keyVal != _propertyMap->end()) {
 
   72         if (keyVal->second == *
this) {
 
   79         _propertyMap->erase(keyVal);
 
   86     return (_lambdaEff == rhs._lambdaEff);
 
   91 void FilterProperty::_initRegistry() {
 
   96     _propertyMap = 
new PropertyMap;
 
  104     PropertyMap::iterator keyVal = _propertyMap->find(
name);
 
  106     if (keyVal == _propertyMap->end()) {
 
  110     return keyVal->second;
 
  117 int const Filter::AUTO = -1;
 
  118 int const Filter::UNKNOWN = -1;
 
  122     if (metadata->exists(key)) {
 
  123         std::string filterName = boost::algorithm::trim_right_copy(metadata->getAsString(key));
 
  124         _id = _lookup(filterName, force);
 
  134     if (metadata->
exists(key)) {
 
  147     std::string const& canonicalName = getCanonicalName();
 
  148     for (
auto const &
ptr : *_aliasMap) {
 
  149         if (
ptr.second == canonicalName) {
 
  164     for (
auto const &
ptr : *_nameMap) {
 
  165         if (
ptr.first != unknownFilter) {
 
  175     return std::make_unique<Filter>(*
this);
 
  178 bool Filter::equals(typehandling::Storable 
const& other) 
const noexcept {
 
  179     return singleClassEquals(*
this, other);
 
  184 struct PersistenceHelper {
 
  188     static PersistenceHelper 
const& get() {
 
  189         static PersistenceHelper 
const instance;
 
  194     PersistenceHelper() : 
schema(), 
name(
schema.addField<
std::string>(
"name", 
"name of the filter")) {}
 
  197 class FilterFactory : 
public table::io::PersistableFactory {
 
  200                                                  CatalogVector 
const& catalogs)
 const override {
 
  201         PersistenceHelper 
const& 
keys = PersistenceHelper::get();
 
  204         return std::make_shared<Filter>(catalogs.front().begin()->get(
keys.name), 
true);
 
  210 std::string _getPersistenceName() { 
return "Filter"; }
 
  212 FilterFactory registration(_getPersistenceName());
 
  216 bool Filter::isPersistable() const noexcept { 
return true; }
 
  223     PersistenceHelper 
const& 
keys = PersistenceHelper::get();
 
  227     handle.saveCatalog(catalog);
 
  234 void Filter::_initRegistry() {
 
  240     _aliasMap = 
new AliasMap;
 
  241     _nameMap = 
new NameMap;
 
  244     define(
FilterProperty(unknownFilter, daf::base::PropertySet(), 
true));
 
  247 int Filter::_id0 = Filter::UNKNOWN;
 
  250 Filter::AliasMap* Filter::_aliasMap = 
nullptr;
 
  251 Filter::NameMap* Filter::_nameMap = 
nullptr;
 
  252 Filter::IdMap* Filter::_idMap = 
nullptr;
 
  254 int Filter::define(
FilterProperty const& fp, 
int id, 
bool force) {
 
  260     NameMap::iterator keyVal = _nameMap->find(
name);
 
  262     if (keyVal != _nameMap->end()) {
 
  263         int oid = keyVal->second;
 
  265         if (
id == oid || 
id == AUTO) {
 
  272         _nameMap->erase(keyVal);
 
  293     NameMap::iterator keyVal = _nameMap->find(oldName);
 
  294     if (keyVal == _nameMap->end()) {
 
  297     int const id = keyVal->second;
 
  300     AliasMap::iterator aliasKeyVal = _aliasMap->find(newName);
 
  301     if (aliasKeyVal != _aliasMap->end()) {
 
  302         if (aliasKeyVal->second == oldName) {
 
  309         _aliasMap->erase(aliasKeyVal);
 
  322     NameMap::iterator keyVal = _nameMap->find(
name);
 
  324     if (keyVal == _nameMap->end()) {
 
  325         AliasMap::iterator aliasKeyVal = _aliasMap->find(
name);
 
  326         if (aliasKeyVal != _aliasMap->end()) {
 
  327             return _lookup(aliasKeyVal->second);
 
  337     return keyVal->second;
 
  345     IdMap::iterator keyVal = _idMap->find(
id);
 
  347     if (keyVal == _idMap->end()) {
 
  351     return keyVal->second;
 
  357     int const id = _lookup(_name, 
true);
 
  360     return FilterProperty::lookup(
name);
 
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
 
table::Key< std::string > name
 
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
 
Class for storing generic metadata.
 
virtual void remove(std::string const &name)
Remove all values for a property name (possibly hierarchical).
 
bool exists(std::string const &name) const
Determine if a name (possibly hierarchical) exists.
 
double getAsDouble(std::string const &name) const
Get the last value for any arithmetic property name (possibly hierarchical).
 
Reports attempts to access elements using an invalid key.
 
Reports errors that are due to events beyond the control of the program.
 
int stripFilterKeywords(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Remove Filter-related keywords from the metadata.
 
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
 
bool operator==(FilterProperty const &rhs) const noexcept
Return true iff two FilterProperties are identical.
 
std::string getPythonModule() const override
 
std::string getPersistenceName() const override
 
@ UNKNOWN
Rotation angle is unknown.
 
void write(OutputArchiveHandle &handle) const override
 
std::size_t hash_value() const noexcept
Return a hash of this object.
 
std::string const  & getName() const noexcept
Return a filter's name.
 
FilterProperty(FilterProperty const &)=default
 
CatalogT< BaseRecord > BaseCatalog
 
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
 
A base class for image defects.
 
std::shared_ptr< table::io::Persistable > read(table::io::InputArchive const &archive, table::io::CatalogVector const &catalogs) const override