LSSTApplications  19.0.0-11-g2ce9f25+4,20.0.0+1,20.0.0+10,20.0.0+11,20.0.0+13,20.0.0+2,20.0.0+3,20.0.0+4,20.0.0+6,20.0.0-1-g10df615+10,20.0.0-1-g253301a+5,20.0.0-1-g596936a+11,20.0.0-1-g8a53f90+1,20.0.0-1-gc96f8cb+12,20.0.0-1-gd1c87d7+1,20.0.0-17-g41c5faf,20.0.0-2-g04cfba9+4,20.0.0-2-gd11eeda,20.0.0-2-gec03fae+3,20.0.0-3-g082faa5+1,20.0.0-3-gbdbfa727+3,20.0.0-3-gc53c7b6,20.0.0-4-gde602ef96+4,20.0.0-4-ge48a6ca+6,20.0.0-4-ge987224+1,20.0.0-8-g7eef53f7+7,20.0.0-9-g8e1b333,w.2020.28
LSSTDataManagementBasePackage
Public Member Functions | Static Public Member Functions | Protected Types | List of all members
lsst::afw::table::io::PersistableFactory Class Referenceabstract

A base class for factory classes used to reconstruct objects from records. More...

#include <Persistable.h>

Inheritance diagram for lsst::afw::table::io::PersistableFactory:
lsst::afw::cameraGeom::Camera::Factory lsst::afw::cameraGeom::Detector::Factory lsst::afw::cameraGeom::DetectorCollection::Factory lsst::afw::cameraGeom::TransformMap::Factory lsst::afw::detection::FootprintFactory lsst::afw::detection::HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT >::Factory lsst::afw::math::AnalyticKernel::Factory lsst::afw::math::DeltaFunctionKernel::Factory lsst::afw::math::FixedKernel::Factory lsst::afw::math::LinearCombinationKernel::Factory lsst::meas::algorithms::CoaddBoundedField::Factory lsst::meas::algorithms::CoaddPsf::Factory lsst::meas::algorithms::KernelPsfFactory< T, K >

Public Member Functions

 PersistableFactory (std::string const &name)
 Constructor for the factory. More...
 
virtual std::shared_ptr< Persistableread (InputArchive const &archive, CatalogVector const &catalogs) const =0
 Construct a new object from the given InputArchive and vector of catalogs. More...
 
virtual ~PersistableFactory () noexcept=default
 
 PersistableFactory (const PersistableFactory &)=delete
 
PersistableFactoryoperator= (const PersistableFactory &)=delete
 
 PersistableFactory (PersistableFactory &&)=delete
 
PersistableFactoryoperator= (PersistableFactory &&)=delete
 

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

Protected Types

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

Detailed Description

A base class for factory classes used to reconstruct objects from records.

Classes that inherit from Persistable should also subclass PersistableFactory, and instantiate exactly one instance of the derived factory with static duration (usually the class and instance are both defined in an anonymous namespace in a source file).

Definition at line 228 of file Persistable.h.

Member Typedef Documentation

◆ CatalogVector

Definition at line 231 of file Persistable.h.

◆ InputArchive

Definition at line 230 of file Persistable.h.

Constructor & Destructor Documentation

◆ PersistableFactory() [1/3]

lsst::afw::table::io::PersistableFactory::PersistableFactory ( std::string const &  name)
explicit

Constructor for the factory.

This should be called only once, and only on an object with static duration, as a pointer to the object will be put in a singleton registry.

The name must be globally unique with respect to all Persistables and be the same as Persistable::getPersistenceName(); the Python module that a Persistable may also declare is not used to resolve names, but rather just to import the module that may install the necessary factory in the registry.

Definition at line 74 of file Persistable.cc.

74 { getRegistry()[name] = this; }

◆ ~PersistableFactory()

virtual lsst::afw::table::io::PersistableFactory::~PersistableFactory ( )
virtualdefaultnoexcept

◆ PersistableFactory() [2/3]

lsst::afw::table::io::PersistableFactory::PersistableFactory ( const PersistableFactory )
delete

◆ PersistableFactory() [3/3]

lsst::afw::table::io::PersistableFactory::PersistableFactory ( PersistableFactory &&  )
delete

Member Function Documentation

◆ lookup()

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

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 }

◆ operator=() [1/2]

PersistableFactory& lsst::afw::table::io::PersistableFactory::operator= ( const PersistableFactory )
delete

◆ operator=() [2/2]

PersistableFactory& lsst::afw::table::io::PersistableFactory::operator= ( PersistableFactory &&  )
delete

◆ read()

virtual std::shared_ptr<Persistable> lsst::afw::table::io::PersistableFactory::read ( InputArchive const &  archive,
CatalogVector const &  catalogs 
) const
pure virtual

The documentation for this class was generated from the following files:
pex.config.history.format
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
lsst::afw::geom.transform.transformContinued.name
string name
Definition: transformContinued.py:32
end
int end
Definition: BoundedField.cc:105
lsst::base::ModuleImporter::import
static bool import(std::string const &name)
Import the given Python module, and return true if successful.
Definition: ModuleImporter.cc:49
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::meas::modelfit.psf.psfContinued.module
module
Definition: psfContinued.py:42