LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+f5613e8b4f,g1470d8bcf6+190ad2ba91,g14a832a312+311607e4ab,g2079a07aa2+86d27d4dc4,g2305ad1205+a8e3196225,g295015adf3+b67ee847e5,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+a761f810f3,g487adcacf7+17c8fdbcbd,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+65b5bd823e,g5a732f18d5+53520f316c,g64a986408d+f5613e8b4f,g6c1bc301e9+51106c2951,g858d7b2824+f5613e8b4f,g8a8a8dda67+585e252eca,g99cad8db69+6729933424,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+ef4e3a5875,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+e9bba80f27,gc120e1dc64+eee469a5e5,gc28159a63d+0e5473021a,gcf0d15dbbd+a761f810f3,gdaeeff99f8+f9a426f77a,ge6526c86ff+d4c1d4bfef,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf1cff7945b+f5613e8b4f,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Types | List of all members
lsst::afw::cameraGeom::TransformMap::Factory Class Reference
Inheritance diagram for lsst::afw::cameraGeom::TransformMap::Factory:
lsst::afw::table::io::PersistableFactory

Public Member Functions

 Factory ()
 
std::shared_ptr< PersistablereadOld (InputArchive const &archive, CatalogVector const &catalogs) const
 
std::shared_ptr< Persistableread (InputArchive const &archive, CatalogVector const &catalogs) const override
 Construct a new object from the given InputArchive and vector of catalogs.
 

Static Public Member Functions

static PersistableFactory const & lookup (std::string const &name, std::string const &module="")
 Return the factory that has been registered with the given name.
 

Static Public Attributes

static Factory const registration
 

Protected Types

using InputArchive = io::InputArchive
 
using CatalogVector = io::CatalogVector
 

Detailed Description

Definition at line 404 of file TransformMap.cc.

Member Typedef Documentation

◆ CatalogVector

using lsst::afw::table::io::PersistableFactory::CatalogVector = io::CatalogVector
protectedinherited

Definition at line 231 of file Persistable.h.

◆ InputArchive

using lsst::afw::table::io::PersistableFactory::InputArchive = io::InputArchive
protectedinherited

Definition at line 230 of file Persistable.h.

Constructor & Destructor Documentation

◆ Factory()

lsst::afw::cameraGeom::TransformMap::Factory::Factory ( )
inline

Definition at line 407 of file TransformMap.cc.

407: PersistableFactory("TransformMap") {}
PersistableFactory(std::string const &name)
Constructor for the factory.

Member Function Documentation

◆ lookup()

PersistableFactory const & lsst::afw::table::io::PersistableFactory::lookup ( std::string const & name,
std::string const & module = "" )
staticinherited

Return the factory that has been registered with the given name.

If the lookup fails and module is not an empty string, we will attempt to import a Python module with that name (this will only work when the C++ is being called from Python) and try again.

Definition at line 76 of file Persistable.cc.

76 {
77 RegistryMap::const_iterator i = getRegistry().find(name);
78 if (i == getRegistry().end()) {
79 if (!module.empty()) {
80 bool success = base::ModuleImporter::import(module);
81 if (!success) {
82 throw LSST_EXCEPT(
83 pex::exceptions::NotFoundError,
84 (boost::format(
85 "PersistableFactory with name '%s' not found, and import of module "
86 "'%s' failed (possibly because Python calls were not available from C++).") %
87 name % module)
88 .str());
89 }
90 i = getRegistry().find(name);
91 if (i == getRegistry().end()) {
92 throw LSST_EXCEPT(
93 pex::exceptions::LogicError,
94 (boost::format(
95 "PersistableFactory with name '%s' not found even after successful import "
96 "of module '%s'. Please report this as a bug in the persistence "
97 "implementation for this object.") %
98 name % module)
99 .str());
100 }
101 } else {
102 throw LSST_EXCEPT(
103 pex::exceptions::LogicError,
104 (boost::format(
105 "PersistableFactory with name '%s' not found, and no Python module to import "
106 "was provided. Please report this as a bug in the persistence implementation "
107 "for this object.") %
108 name)
109 .str());
110 }
111 }
112 return *i->second;
113}
int end
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48
static bool import(std::string const &name)
Import the given Python module, and return true if successful.

◆ read()

std::shared_ptr< Persistable > lsst::afw::cameraGeom::TransformMap::Factory::read ( InputArchive const & archive,
CatalogVector const & catalogs ) const
inlineoverridevirtual

Construct a new object from the given InputArchive and vector of catalogs.

Implements lsst::afw::table::io::PersistableFactory.

Definition at line 446 of file TransformMap.cc.

447 {
448 if (catalogs.size() == 2u) {
449 return readOld(archive, catalogs);
450 }
451
452 auto const & keys = PersistenceHelper::get();
453
454 LSST_ARCHIVE_ASSERT(catalogs.size() == 1u);
455 auto const & cat = catalogs[0];
456 LSST_ARCHIVE_ASSERT(cat.getSchema() == keys.schema);
457
458 std::vector<Connection> connections;
459 for (auto const & record : cat) {
460 CameraSys const fromSys(record.get(keys.fromSysName), record.get(keys.fromSysDetectorName));
461 CameraSys const toSys(record.get(keys.toSysName), record.get(keys.toSysDetectorName));
462 auto const transform = archive.get<geom::TransformPoint2ToPoint2>(record.get(keys.transform));
463 connections.push_back(Connection{transform, fromSys, toSys});
464 }
465
466 // Deserialized connections should already be standardized, but be
467 // defensive anyway.
468 auto const referenceSys = getReferenceSys(connections);
469 connections = standardizeConnections(referenceSys, std::move(connections));
470 return std::shared_ptr<TransformMap>(new TransformMap(std::move(connections)));
471 }
table::Key< int > transform
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
Definition Persistable.h:48
std::shared_ptr< Persistable > readOld(InputArchive const &archive, CatalogVector const &catalogs) const
TransformMap(TransformMap const &other)=delete
T move(T... args)
T push_back(T... args)

◆ readOld()

std::shared_ptr< Persistable > lsst::afw::cameraGeom::TransformMap::Factory::readOld ( InputArchive const & archive,
CatalogVector const & catalogs ) const
inline

Definition at line 409 of file TransformMap.cc.

410 {
411 auto const & keys = OldPersistenceHelper::get();
412
413 LSST_ARCHIVE_ASSERT(catalogs.size() == 2u);
414 auto const & sysCat = catalogs[0];
415 auto const & connectionCat = catalogs[1];
416 LSST_ARCHIVE_ASSERT(sysCat.getSchema() == keys.sysSchema);
417 LSST_ARCHIVE_ASSERT(connectionCat.getSchema() == keys.connectionSchema);
418 LSST_ARCHIVE_ASSERT(sysCat.size() == connectionCat.size() + 1);
419 LSST_ARCHIVE_ASSERT(sysCat.isSorted(keys.id));
420
422 for (auto const & sysRecord : sysCat) {
423 auto sys = keys.makeCameraSys(sysRecord);
424 sysById.emplace(sysRecord.get(keys.id), sys);
425 }
426
427 auto const referenceSysIter = sysById.find(1);
428 LSST_ARCHIVE_ASSERT(referenceSysIter != sysById.end());
429 std::vector<Connection> connections;
430 for (auto const & connectionRecord : connectionCat) {
431 auto const fromSysIter = sysById.find(connectionRecord.get(keys.from));
432 LSST_ARCHIVE_ASSERT(fromSysIter != sysById.end());
433 auto const toSysIter = sysById.find(connectionRecord.get(keys.to));
434 LSST_ARCHIVE_ASSERT(toSysIter != sysById.end());
435 auto const transform = archive.get<geom::TransformPoint2ToPoint2>(
436 connectionRecord.get(keys.transform)
437 );
438
439 connections.push_back(Connection{transform, fromSysIter->second, toSysIter->second});
440 }
441
442 connections = standardizeConnections(referenceSysIter->second, std::move(connections));
443 return std::shared_ptr<TransformMap>(new TransformMap(std::move(connections)));
444 }
T emplace(T... args)
T end(T... args)
T find(T... args)

Member Data Documentation

◆ registration

TransformMap::Factory const lsst::afw::cameraGeom::TransformMap::Factory::registration
static

Definition at line 473 of file TransformMap.cc.


The documentation for this class was generated from the following file: