LSST Applications g04c3c9f7ca+2075667efa,g1e125bf412+5f448d5fcf,g2079a07aa2+3e9fd84d81,g2305ad1205+b635cf1488,g2bbee38e9b+6c6beb4891,g337abbeb29+6c6beb4891,g33d1c0ed96+6c6beb4891,g3a166c0a6a+6c6beb4891,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+42f171e1e6,g5c3423f6d4+d536b04327,g607f77f49a+d536b04327,g6f43f06aed+ca1339dc19,g858d7b2824+d536b04327,g8ee334c5b4+d7f9608c2f,g9963eaa53e+b3dc1655d3,g998f4353bf+d536b04327,g99cad8db69+8ef2408349,g9ddcbc5298+9a081db1e4,ga1e77700b3+2cbb763275,gadfd92a7e4+aec2f3b930,gae0086650b+585e252eca,gb0e22166c9+0e73c8378f,gb3b7280ab2+cb5fdb229e,gbb8dafda3b+a327199e22,gc120e1dc64+88074880ea,gc28159a63d+6c6beb4891,gcdd4ae20e8+bd241b2308,gcde1bda545+903e937d91,gcf0d15dbbd+bd241b2308,gdaeeff99f8+f9a426f77a,gddc38dedce+585e252eca,ge79ae78c31+6c6beb4891,gfbcc870c63+b310236976,w.2024.23
LSST Data Management Base Package
No Matches
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::image::FilterLabel::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.
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.
virtual ~PersistableFactory () noexcept=default
 PersistableFactory (const PersistableFactory &)=delete
PersistableFactoryoperator= (const PersistableFactory &)=delete
 PersistableFactory (PersistableFactory &&)=delete
PersistableFactoryoperator= (PersistableFactory &&)=delete

Static Public Member Functions

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

Protected Types

using InputArchive = io::InputArchive
using CatalogVector = io::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)

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

74{ getRegistry()[name] = this; }
table::Key< std::string > name

◆ ~PersistableFactory()

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

◆ PersistableFactory() [2/3]

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

◆ PersistableFactory() [3/3]

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

Member Function Documentation

◆ lookup()

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

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

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

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ 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: