36 std::shared_ptr<table::io::Persistable>
const&);
42std::size_t
const ApCorrMap::MAX_NAME_LENGTH;
46 if (i == _internal.end()) {
48 (boost::format(
"Aperture correction with name '%s' not found") % name).str());
55 if (i == _internal.end()) {
65 (boost::format(
"Aperture correction name '%s' exceeds size limit of %d characters") % name %
74struct PersistenceHelper {
79 static PersistenceHelper
const& get() {
80 static PersistenceHelper
const instance;
87 name(schema.addField<
std::string>(
"name",
"name of the aperture correction",
88 ApCorrMap::MAX_NAME_LENGTH)),
89 field(schema.addField<int>(
"field",
"archive ID of the BoundedField object")) {}
92class ApCorrMapFactory :
public table::io::PersistableFactory {
95 CatalogVector
const& catalogs)
const override {
96 PersistenceHelper
const& keys = PersistenceHelper::get();
102 result->set(i->get(keys.name), archive.get<math::BoundedField>(i->get(keys.field)));
107 ApCorrMapFactory(std::string
const& name) : afw::
table::io::PersistableFactory(name) {}
110std::string getApCorrMapPersistenceName() {
return "ApCorrMap"; }
112ApCorrMapFactory registration(getApCorrMapPersistenceName());
117 for (
auto const &i : *
this) {
118 if (!i.second->isPersistable())
return false;
128 PersistenceHelper
const& keys = PersistenceHelper::get();
130 for (
auto const &i : *
this) {
132 record->set(keys.name, i.first);
133 record->set(keys.field, handle.
put(i.second));
139 Internal replacement;
140 for (
auto const &i : *
this) {
141 replacement[i.first] = (*i.second) * scale;
143 _internal = replacement;
148 return std::make_unique<ApCorrMap>(*
this);
#define LSST_EXCEPT(type,...)
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
std::shared_ptr< typehandling::Storable > cloneStorable() const override
Create a new ApCorrMap that is a copy of this one.
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
bool isPersistable() const noexcept override
Whether the map is persistable (true IFF all contained BoundedFields are persistable).
std::string getPythonModule() const override
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
void set(std::string const &name, std::shared_ptr< math::BoundedField > field)
Add or replace an aperture correction.
std::shared_ptr< math::BoundedField > const get(std::string const &name) const
Return the field with the given name, returning an empty pointer when the name is not present.
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
static std::size_t const MAX_NAME_LENGTH
Maximum number of characters for an aperture correction name (required for persistence).
std::shared_ptr< math::BoundedField > const operator[](std::string const &name) const
Return the field with the given name, throwing NotFoundError when the name is not present.
Internal::const_iterator Iterator
Iterator type returned by begin() and end().
ApCorrMap & operator*=(double const scale)
Scale all fields by a constant.
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
CatalogIterator< typename Internal::const_iterator > const_iterator
A class used as a handle to a particular field in a table.
Defines the fields and offsets for a table.
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.
int put(Persistable const *obj, bool permissive=false)
Save an object to the archive and return a unique ID that can be used to retrieve it from an InputArc...
static std::shared_ptr< T > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
io::OutputArchiveHandle OutputArchiveHandle
CatalogT< BaseRecord > BaseCatalog
std::shared_ptr< table::io::Persistable > read(table::io::InputArchive const &archive, table::io::CatalogVector const &catalogs) const override