lsst.afw
20.0.0-14-g1a12fe12b+614f89f815
|
Go to the documentation of this file.
39 using namespace std::string_literals;
46 static std::regex const unsafeCharacters(
"\\W"s);
61 : _hasBand(hasBand), _hasPhysical(hasPhysical), _band(
band), _physical(
physical) {}
80 bool FilterLabel::hasBandLabel() const noexcept {
return _hasBand; }
104 if (_hasBand != rhs._hasBand) {
107 if (_hasBand && _band != rhs._band) {
110 if (_hasPhysical != rhs._hasPhysical) {
113 if (_hasPhysical && _physical != rhs._physical) {
125 _hasPhysical ? _physical :
""s);
137 if (comma) buffer +=
", "s;
142 if (comma) buffer +=
", "s;
152 return std::make_shared<FilterLabel>(*
this);
172 return OptionalString(existsKey, valueKey);
175 OptionalString() noexcept : _exists(), _value() {}
176 OptionalString(table::Key<table::Flag>
const &exists, table::Key<std::string>
const &value) noexcept
177 : _exists(exists), _value(value) {}
181 bool exists = record.get(_exists);
187 record.set(_exists, value.first);
188 record.set(_value, value.first ? value.second :
""s);
191 bool operator==(OptionalString
const &
other)
const noexcept {
192 return _exists ==
other._exists && _value ==
other._value;
196 bool isValid() const noexcept {
return _exists.isValid() && _value.isValid(); }
198 table::Key<table::Flag> getExists() const noexcept {
return _exists; }
199 table::Key<std::string> getValue() const noexcept {
return _value; }
202 table::Key<table::Flag> _exists;
203 table::Key<std::string> _value;
206 struct PersistenceHelper {
211 static PersistenceHelper
const &get() {
212 static PersistenceHelper
const instance;
219 band(OptionalString::addFields(
schema,
"band",
"Name of the band.", 32)),
220 physical(OptionalString::addFields(
schema,
"physical",
"Name of the physical filter.", 32)) {}
223 std::string _getPersistenceName() noexcept {
return "FilterLabel"s; }
231 PersistenceHelper
const &
keys = PersistenceHelper::get();
244 auto const &
keys = PersistenceHelper::get();
252 record.
get(
keys.physical.getExists()), record.
get(
keys.physical.getValue())));
bool hasPhysicalLabel() const noexcept
Return whether the filter label names a physical filter.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
static FilterLabel fromPhysical(std::string const &physical)
Construct a FilterLabel from specific inputs.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
void write(table::io::OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
An object passed to Persistable::write to allow it to persist itself.
Convenience base class that combines the OutputFunctorKey and InputFunctorKey.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
std::shared_ptr< table::io::Persistable > read(table::io::InputArchive const &archive, table::io::CatalogVector const &catalogs) const override
Construct a new object from the given InputArchive and vector of catalogs.
Defines the fields and offsets for a table.
std::string getPhysicalLabel() const
Return the physical filter label.
std::string getPersistenceName() const noexcept override
Return the unique name used to persist this object and look up its factory.
PersistableFactory(std::string const &name)
Constructor for the factory.
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
FilterLabel(FilterLabel const &)
std::string getDatabaseFilterLabel(std::string const &filterLabel)
Remap special characters, etc.
std::shared_ptr< Storable > cloneStorable() const override
Create a new object that is a copy of this one.
daf::base::PropertySet * set
ItemVariant const * other
Base class for all records.
A vector of catalogs used by Persistable.
A class used as a handle to a particular field in a table.
A base class for factory classes used to reconstruct objects from records.
bool hasBandLabel() const noexcept
Return whether the filter label names a band.
A group of labels for a filter in an exposure or coadd.
A base class for image defects.
#define LSST_EXCEPT(type,...)
static std::shared_ptr< T > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
std::string getPythonModule() const noexcept override
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
FilterLabel makeTestFilterLabel(bool hasBand, std::string const &band, bool hasPhysical, std::string const &physical)
static FilterLabel fromBandPhysical(std::string const &band, std::string const &physical)
Construct a FilterLabel from specific inputs.
std::string getBandLabel() const
Return the band label.
std::size_t hashCombine(std::size_t seed) noexcept
std::size_t hash_value() const noexcept override
Return a hash of this object.
std::string toString() const override
Return a string representation of this object.
Schema getSchema() const
Return the Schema that holds this record's fields and keys.
static FilterLabel fromBand(std::string const &band)
Construct a FilterLabel from specific inputs.
bool operator==(FilterLabel const &rhs) const noexcept
Filter labels compare equal if their components are equal.
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
Factory(std::string const &name)
T regex_replace(T... args)