30 namespace cameraGeom {
33 for (
auto const &
detector : detectorList) {
41 if (_idDict.
size() < detectorList.size()) {
44 if (_nameDict.
size() < detectorList.size()) {
69 auto i = _nameDict.
find(name);
70 if (i == _nameDict.
end()) {
77 auto i = _idDict.
find(
id);
78 if (i == _idDict.
end()) {
86 class PersistenceHelper {
89 static PersistenceHelper
const &
get() {
90 static PersistenceHelper
const instance;
98 table::io::InputArchive
const & archive,
99 table::io::CatalogVector
const & catalogs
104 result.reserve(catalogs.front().size());
105 for (
auto const & record : catalogs.front()) {
106 int archiveId = record.get(detector);
107 result.push_back(archive.get<Detector>(archiveId));
114 PersistenceHelper() :
116 detector(schema.addField<
int>(
"detector",
"archive ID of Detector in a DetectorCollection"))
118 schema.getCitizen().markPersistent();
121 PersistenceHelper(PersistenceHelper
const &) =
delete;
122 PersistenceHelper(PersistenceHelper &&) =
delete;
124 PersistenceHelper &
operator=(PersistenceHelper
const &) =
delete;
125 PersistenceHelper &
operator=(PersistenceHelper &&) =
delete;
135 Factory() : table::io::PersistableFactory(
"DetectorCollection") {}
156 return "DetectorCollection";
160 return "lsst.afw.cameraGeom";
164 auto const &
keys = PersistenceHelper::get();
166 for (
auto const & pair :
getIdMap()) {
167 auto record = cat.
addNew();
168 record->set(
keys.detector, handle.
put(pair.second));
178 template class PersistableFacade<cameraGeom::DetectorCollection>;
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 Factory const registration
An object passed to Persistable::write to allow it to persist itself.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
void include(Point2D const &point) noexcept
A base class for factory classes used to reconstruct objects from records.
table::Key< int > detector
std::vector< std::shared_ptr< Detector > > List
DetectorCollection(List const &detectorList)
std::string getPythonModule() const override
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
A base class for image defects.
std::shared_ptr< Detector > get(std::string const &name, std::shared_ptr< Detector > def=nullptr) const
Support the "in" operator.
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
virtual ~DetectorCollection() noexcept
std::shared_ptr< Detector > operator[](std::string const &name) const
Implement the [name] operator.
std::unique_ptr< SchemaItem< U > > result
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
An immutable collection of Detectors that can be accessed by name or ID.
#define LSST_EXCEPT(type,...)
A vector of catalogs used by Persistable.
std::shared_ptr< Persistable > read(InputArchive const &archive, CatalogVector const &catalogs) const override
Construct a new object from the given InputArchive and vector of catalogs.
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
DetectorCollection & operator=(DetectorCollection const &)=delete
IdMap const & getIdMap() const noexcept
Get an unordered map over detector IDs.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
CameraSys const FOCAL_PLANE
Focal plane coordinates: Rectilinear x, y (and z when talking about the location of a detector) on th...
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.