LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
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. More...
 

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. More...
 

Static Public Attributes

static Factory const registration
 

Protected Types

typedef io::InputArchive InputArchive
 
typedef io::CatalogVector CatalogVector
 

Detailed Description

Definition at line 405 of file TransformMap.cc.

Member Typedef Documentation

◆ CatalogVector

typedef io::CatalogVector lsst::afw::table::io::PersistableFactory::CatalogVector
protectedinherited

Definition at line 231 of file Persistable.h.

◆ InputArchive

typedef io::InputArchive lsst::afw::table::io::PersistableFactory::InputArchive
protectedinherited

Definition at line 230 of file Persistable.h.

Constructor & Destructor Documentation

◆ Factory()

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

Definition at line 408 of file TransformMap.cc.

408 : PersistableFactory("TransformMap") {}
PersistableFactory(std::string const &name)
Constructor for the factory.
Definition: Persistable.cc:74

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,
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,
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 }
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
#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.
int end

◆ 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 447 of file TransformMap.cc.

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

◆ readOld()

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

Definition at line 410 of file TransformMap.cc.

411  {
412  auto const & keys = OldPersistenceHelper::get();
413 
414  LSST_ARCHIVE_ASSERT(catalogs.size() == 2u);
415  auto const & sysCat = catalogs[0];
416  auto const & connectionCat = catalogs[1];
417  LSST_ARCHIVE_ASSERT(sysCat.getSchema() == keys.sysSchema);
418  LSST_ARCHIVE_ASSERT(connectionCat.getSchema() == keys.connectionSchema);
419  LSST_ARCHIVE_ASSERT(sysCat.size() == connectionCat.size() + 1);
420  LSST_ARCHIVE_ASSERT(sysCat.isSorted(keys.id));
421 
423  for (auto const & sysRecord : sysCat) {
424  auto sys = keys.makeCameraSys(sysRecord);
425  sysById.emplace(sysRecord.get(keys.id), sys);
426  }
427 
428  auto const referenceSysIter = sysById.find(1);
429  LSST_ARCHIVE_ASSERT(referenceSysIter != sysById.end());
430  std::vector<Connection> connections;
431  for (auto const & connectionRecord : connectionCat) {
432  auto const fromSysIter = sysById.find(connectionRecord.get(keys.from));
433  LSST_ARCHIVE_ASSERT(fromSysIter != sysById.end());
434  auto const toSysIter = sysById.find(connectionRecord.get(keys.to));
435  LSST_ARCHIVE_ASSERT(toSysIter != sysById.end());
436  auto const transform = archive.get<geom::TransformPoint2ToPoint2>(
437  connectionRecord.get(keys.transform)
438  );
439 
440  connections.push_back(Connection{transform, fromSysIter->second, toSysIter->second});
441  }
442 
443  connections = standardizeConnections(referenceSysIter->second, std::move(connections));
444  return std::shared_ptr<TransformMap>(new TransformMap(std::move(connections)));
445  }
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
Definition: Persistable.h:48
lsst::geom::Point2D transform(lsst::geom::Point2D const &point, CameraSys const &fromSys, CameraSys const &toSys) const
Convert a point from one camera coordinate system to another.
Transform< Point2Endpoint, Point2Endpoint > TransformPoint2ToPoint2
Definition: Transform.h:300
T move(T... args)
TransformMap(TransformMap const &other)=delete
STL class.

Member Data Documentation

◆ registration

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

Definition at line 474 of file TransformMap.cc.


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