39 using namespace std::string_literals;
46 static std::regex const unsafeCharacters(
"\\W"s);
61 : _hasBand(hasBand), _hasPhysical(hasPhysical), _band(
band), _physical(
physical) {
63 if (!hasBand && !hasPhysical) {
85 bool FilterLabel::hasBandLabel() const noexcept {
return _hasBand; }
109 if (_hasBand != rhs._hasBand) {
112 if (_hasBand && _band != rhs._band) {
115 if (_hasPhysical != rhs._hasPhysical) {
118 if (_hasPhysical && _physical != rhs._physical) {
130 _hasPhysical ? _physical :
""s);
142 if (comma) buffer +=
", "s;
147 if (comma) buffer +=
", "s;
157 return std::make_shared<FilterLabel>(*
this);
177 return OptionalString(existsKey, valueKey);
180 OptionalString() noexcept : _exists(), _value() {}
182 : _exists(exists), _value(value) {}
186 bool exists = record.get(_exists);
192 record.set(_exists, value.first);
193 record.set(_value, value.first ? value.second :
""s);
196 bool operator==(OptionalString
const &other)
const noexcept {
197 return _exists == other._exists && _value == other._value;
199 bool operator!=(OptionalString
const &other)
const noexcept {
return !(*
this == other); }
201 bool isValid() const noexcept {
return _exists.isValid() && _value.isValid(); }
203 table::Key<table::Flag> getExists() const noexcept {
return _exists; }
204 table::Key<std::string> getValue() const noexcept {
return _value; }
207 table::Key<table::Flag> _exists;
208 table::Key<std::string> _value;
211 struct PersistenceHelper {
216 static PersistenceHelper
const &get() {
217 static PersistenceHelper
const instance;
224 band(OptionalString::addFields(
schema,
"band",
"Name of the band.", 32)),
225 physical(OptionalString::addFields(
schema,
"physical",
"Name of the physical filter.", 32)) {}
228 std::string _getPersistenceName() noexcept {
return "FilterLabel"s; }
236 PersistenceHelper
const &
keys = PersistenceHelper::get();
249 auto const &
keys = PersistenceHelper::get();
257 record.
get(
keys.physical.getExists()), record.
get(
keys.physical.getValue())));
table::Key< std::string > name
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
Factory(std::string const &name)
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.
A group of labels for a filter in an exposure or coadd.
std::string getBandLabel() const
Return the band label.
std::string getPersistenceName() const noexcept override
Return the unique name used to persist this object and look up its factory.
bool hasBandLabel() const noexcept
Return whether the filter label names a band.
static FilterLabel fromBand(std::string const &band)
Construct a FilterLabel from specific inputs.
std::string getPythonModule() const noexcept override
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
bool hasPhysicalLabel() const noexcept
Return whether the filter label names a physical filter.
void write(table::io::OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
std::string toString() const override
Return a string representation of this object.
std::size_t hash_value() const noexcept override
Return a hash of this object.
std::shared_ptr< Storable > cloneStorable() const override
Create a new object that is a copy of this one.
std::string getPhysicalLabel() const
Return the physical filter label.
bool operator==(FilterLabel const &rhs) const noexcept
Filter labels compare equal if their components are equal.
static FilterLabel fromBandPhysical(std::string const &band, std::string const &physical)
Construct a FilterLabel from specific inputs.
FilterLabel(FilterLabel const &)
static FilterLabel fromPhysical(std::string const &physical)
Construct a FilterLabel from specific inputs.
Base class for all records.
Schema getSchema() const
Return the Schema that holds this record's fields and keys.
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
Convenience base class that combines the OutputFunctorKey and InputFunctorKey.
A class used as a handle to a particular field in a table.
Defines the fields and offsets for a table.
A vector of catalogs used by Persistable.
An object passed to Persistable::write to allow it to persist itself.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
static std::shared_ptr< T > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
A base class for factory classes used to reconstruct objects from records.
PersistableFactory(std::string const &name)
Constructor for the factory.
Reports errors in the logical structure of the program.
daf::base::PropertySet * set
FilterLabel makeTestFilterLabel(bool hasBand, std::string const &band, bool hasPhysical, std::string const &physical)
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
std::string getDatabaseFilterLabel(std::string const &filterLabel)
Remap special characters, etc.
bool operator==(FilterProperty const &rhs) const noexcept
Return true iff two FilterProperties are identical.
bool operator!=(FilterProperty const &rhs) const noexcept
Return true iff rhs != this.
std::size_t hashCombine(std::size_t seed) noexcept
Combine hashes.
A base class for image defects.
T regex_replace(T... args)