LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Related Functions | List of all members
lsst::afw::typehandling::Storable Class Referenceabstract

Interface supporting iteration over heterogenous containers. More...

#include <Storable.h>

Inheritance diagram for lsst::afw::typehandling::Storable:
lsst::afw::table::io::Persistable lsst::afw::cameraGeom::Detector lsst::afw::detection::Psf lsst::afw::geom::SkyWcs lsst::afw::geom::polygon::Polygon lsst::afw::image::ApCorrMap lsst::afw::image::CoaddInputs lsst::afw::image::FilterLabel lsst::afw::image::PhotoCalib lsst::afw::image::TransmissionCurve lsst::afw::image::VisitInfo lsst.afw.image._exposureSummaryStats.ExposureSummaryStats lsst::afw::typehandling::StorableHelper< Base > lsst.afw.typehandling.testUtils.GenericMapTestBaseClass.SimpleStorable

Public Member Functions

virtual ~Storable () noexcept=0
 
virtual std::shared_ptr< StorablecloneStorable () const
 Create a new object that is a copy of this one (optional operation). More...
 
virtual std::string toString () const
 Create a string representation of this object (optional operation). More...
 
virtual std::size_t hash_value () const
 Return a hash of this object (optional operation). More...
 
virtual bool equals (Storable const &other) const noexcept
 Compare this object to another Storable. More...
 
void writeFits (std::string const &fileName, std::string const &mode="w") const
 Write the object to a regular FITS file. More...
 
void writeFits (fits::MemFileManager &manager, std::string const &mode="w") const
 Write the object to a FITS image in memory. More...
 
void writeFits (fits::Fits &fitsfile) const
 Write the object to an already-open FITS object. More...
 
virtual bool isPersistable () const noexcept
 Return true if this particular object can be persisted using afw::table::io. More...
 

Protected Types

using OutputArchiveHandle = io::OutputArchiveHandle
 

Protected Member Functions

virtual std::string getPersistenceName () const
 Return the unique name used to persist this object and look up its factory. More...
 
virtual std::string getPythonModule () const
 Return the fully-qualified Python module that should be imported to guarantee that its factory is registered. More...
 
virtual void write (OutputArchiveHandle &handle) const
 Write the object to one or more catalogs. More...
 

Static Protected Member Functions

template<class T >
static bool singleClassEquals (T const &lhs, Storable const &rhs)
 Test if a Storable is of a particular class and equal to another object. More...
 

Related Functions

(Note that these are not member functions.)

std::ostreamoperator<< (std::ostream &os, Storable const &storable)
 Output operator for Storable. More...
 

Detailed Description

Interface supporting iteration over heterogenous containers.

Storable may be subclassed by either C++ or Python classes. Many operations defined by Storable are optional, and may throw UnsupportedOperationException if they are not defined.

Note
Any C++ subclass X of Storable that supports Python subclasses must have a pybind11 wrapper that uses StorableHelper<X> (or a subclass) and lsst::utils::python::PySharedPtr.

Definition at line 58 of file Storable.h.

Member Typedef Documentation

◆ OutputArchiveHandle

using lsst::afw::table::io::Persistable::OutputArchiveHandle = io::OutputArchiveHandle
protectedinherited

Definition at line 108 of file Persistable.h.

Constructor & Destructor Documentation

◆ ~Storable()

lsst::afw::typehandling::Storable::~Storable ( )
pure virtualdefaultnoexcept

Member Function Documentation

◆ cloneStorable()

std::shared_ptr< Storable > lsst::afw::typehandling::Storable::cloneStorable ( ) const
virtual

Create a new object that is a copy of this one (optional operation).

This operation is required for Storables that are stored in GenericMap by value, but not for those stored by shared pointer.

Exceptions
UnsupportedOperationExceptionThrown if this object is not cloneable.
Note
If this class supports a clone operation, the two should behave identically except for the formal return type.
When called on Python classes, this method delegates to __deepcopy__ if it exists.

Reimplemented in lsst::afw::typehandling::StorableHelper< Base >, lsst::afw::image::VisitInfo, lsst::afw::image::PhotoCalib, lsst::afw::image::FilterLabel, lsst::afw::image::CoaddInputs, lsst::afw::image::ApCorrMap, lsst::afw::geom::SkyWcs, lsst::afw::geom::polygon::Polygon, and lsst::afw::detection::Psf.

Definition at line 36 of file Storable.cc.

36  {
37  throw LSST_EXCEPT(UnsupportedOperationException, "Cloning is not supported.");
38 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ equals()

bool lsst::afw::typehandling::Storable::equals ( Storable const &  other) const
virtualnoexcept

Compare this object to another Storable.

Subclasses that implement equality comparison must override this method to give results consistent with operator== for all inputs that are accepted by both.

Returns
This implementation returns whether the two objects are the same.
Warning
This method compares an object to any type of Storable, although cross-class comparisons should usually return false. If cross-class comparisons are valid, implementers should take care that they are symmetric and will give the same result no matter what the compile-time types of the left- and right-hand sides are.
See also
singleClassEquals
Note
When called on Python classes, this method delegates to __eq__ if it exists.

Reimplemented in lsst::afw::image::VisitInfo, lsst::afw::image::PhotoCalib, lsst::afw::geom::SkyWcs, lsst::afw::geom::polygon::Polygon, and lsst::afw::typehandling::StorableHelper< Base >.

Definition at line 48 of file Storable.cc.

48 { return this == &other; }

◆ getPersistenceName()

std::string lsst::afw::table::io::Persistable::getPersistenceName ( ) const
protectedvirtualinherited

Return the unique name used to persist this object and look up its factory.

Must be less than ArchiveIndexSchema::MAX_NAME_LENGTH characters.

Reimplemented in lsst::meas::modelfit::Mixture, lsst::meas::algorithms::WarpedPsf, lsst::meas::algorithms::SingleGaussianPsf, lsst::meas::algorithms::KernelPsf, lsst::meas::algorithms::DoubleGaussianPsf, lsst::meas::algorithms::CoaddPsf, lsst::meas::algorithms::CoaddBoundedField, lsst::afw::typehandling::StorableHelper< Base >, lsst::afw::math::WarpingControl, lsst::afw::math::NearestWarpingKernel, lsst::afw::math::BilinearWarpingKernel, lsst::afw::math::LanczosWarpingKernel, lsst::afw::math::TransformBoundedField, lsst::afw::math::ProductBoundedField, lsst::afw::math::PixelAreaBoundedField, lsst::afw::math::LinearCombinationKernel, lsst::afw::math::DeltaFunctionKernel, lsst::afw::math::AnalyticKernel, lsst::afw::math::FixedKernel, lsst::afw::math::Chebyshev1Function2< ReturnT >, lsst::afw::math::PolynomialFunction2< ReturnT >, lsst::afw::math::DoubleGaussianFunction2< ReturnT >, lsst::afw::math::GaussianFunction2< ReturnT >, lsst::afw::math::ChebyshevBoundedField, lsst::afw::image::VisitInfo, lsst::afw::image::PhotoCalib, lsst::afw::image::CoaddInputs, lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >, lsst::afw::geom::Transform< afw::geom::Point2Endpoint, afw::geom::GenericEndpoint >, lsst::afw::geom::SkyWcs, lsst::afw::geom::polygon::Polygon, lsst::afw::detection::HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT >, lsst::afw::detection::GaussianPsf, lsst::afw::detection::Footprint, lsst::afw::cameraGeom::DetectorCollection, and lsst::afw::image::FilterLabel.

Definition at line 34 of file Persistable.cc.

34 { return std::string(); }

◆ getPythonModule()

std::string lsst::afw::table::io::Persistable::getPythonModule ( ) const
protectedvirtualinherited

◆ hash_value()

std::size_t lsst::afw::typehandling::Storable::hash_value ( ) const
virtual

Return a hash of this object (optional operation).

Exceptions
UnsupportedOperationExceptionThrown if this object is not hashable.
Note
C++ subclass authors are responsible for any associated specializations of std::hash.
When called on Python classes, this method delegates to __hash__ if it exists.

Reimplemented in lsst::afw::typehandling::StorableHelper< Base >, lsst::afw::image::VisitInfo, lsst::afw::image::FilterLabel, and lsst::afw::geom::polygon::Polygon.

Definition at line 44 of file Storable.cc.

44  {
45  throw LSST_EXCEPT(UnsupportedOperationException, "Hashes are not supported.");
46 }

◆ isPersistable()

virtual bool lsst::afw::table::io::Persistable::isPersistable ( ) const
inlinevirtualnoexceptinherited

Return true if this particular object can be persisted using afw::table::io.

Reimplemented in lsst::meas::modelfit::Mixture, lsst::meas::extensions::psfex::PsfexPsf, lsst::meas::algorithms::WarpedPsf, lsst::meas::algorithms::SingleGaussianPsf, lsst::meas::algorithms::KernelPsf, lsst::meas::algorithms::DoubleGaussianPsf, lsst::meas::algorithms::CoaddPsf, lsst::meas::algorithms::CoaddBoundedField, lsst::afw::typehandling::StorableHelper< Base >, lsst::afw::math::WarpingControl, lsst::afw::math::NearestWarpingKernel, lsst::afw::math::BilinearWarpingKernel, lsst::afw::math::LanczosWarpingKernel, lsst::afw::math::TransformBoundedField, lsst::afw::math::ProductBoundedField, lsst::afw::math::PixelAreaBoundedField, lsst::afw::math::LinearCombinationKernel, lsst::afw::math::DeltaFunctionKernel, lsst::afw::math::AnalyticKernel, lsst::afw::math::FixedKernel, lsst::afw::math::Chebyshev1Function2< ReturnT >, lsst::afw::math::PolynomialFunction2< ReturnT >, lsst::afw::math::DoubleGaussianFunction2< ReturnT >, lsst::afw::math::GaussianFunction2< ReturnT >, lsst::afw::math::ChebyshevBoundedField, lsst::afw::image::VisitInfo, lsst::afw::image::PhotoCalib, lsst::afw::image::FilterLabel, lsst::afw::image::CoaddInputs, lsst::afw::image::ApCorrMap, lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >, lsst::afw::geom::Transform< afw::geom::Point2Endpoint, afw::geom::GenericEndpoint >, lsst::afw::geom::SpanSet, lsst::afw::geom::SkyWcs, lsst::afw::geom::polygon::Polygon, lsst::afw::detection::GaussianPsf, lsst::afw::detection::Footprint, lsst::afw::cameraGeom::TransformMap, lsst::afw::cameraGeom::DetectorCollection, lsst::afw::cameraGeom::Detector, and lsst::afw::cameraGeom::Camera.

Definition at line 102 of file Persistable.h.

102 { return false; }

◆ singleClassEquals()

template<class T >
static bool lsst::afw::typehandling::Storable::singleClassEquals ( T const &  lhs,
Storable const &  rhs 
)
inlinestaticprotected

Test if a Storable is of a particular class and equal to another object.

This method template simplifies implementations of equals that delegate to operator== without supporting cross-class comparisons.

Template Parameters
TThe class expected of the two objects to be compared.
Parameters
lhs,rhsThe objects to compare. Note that rhs need not be a T, while lhs must be.
Returns
true if rhs is a T and lhs == rhs; false otherwise.
Exception Safety
Provides the same level of exception safety as operator==. Most implementations of operator== do not throw.
Note
This method template calls operator== with both arguments of compile-time type T const&. Its use is not recommended if there would be any ambiguity as to which operator== gets picked by overload resolution.

This method template is typically called from equals as:

bool MyType::equals(Storable const& other) const noexcept {
    return singleClassEquals(*this, other);
}

Definition at line 151 of file Storable.h.

151  {
152  auto typedRhs = dynamic_cast<T const*>(&rhs);
153  if (typedRhs != nullptr) {
154  return lhs == *typedRhs;
155  } else {
156  return false;
157  }
158  }

◆ toString()

std::string lsst::afw::typehandling::Storable::toString ( ) const
virtual

Create a string representation of this object (optional operation).

Exceptions
UnsupportedOperationExceptionThrown if this object does not have a string representation.
Note
When called on Python classes, this method delegates to __repr__.

Reimplemented in lsst::afw::typehandling::StorableHelper< Base >, lsst::afw::image::VisitInfo, lsst::afw::image::PhotoCalib, lsst::afw::image::FilterLabel, lsst::afw::geom::SkyWcs, and lsst::afw::geom::polygon::Polygon.

Definition at line 40 of file Storable.cc.

40  {
41  throw LSST_EXCEPT(UnsupportedOperationException, "No string representation available.");
42 }

◆ write()

void lsst::afw::table::io::Persistable::write ( OutputArchiveHandle handle) const
protectedvirtualinherited

Write the object to one or more catalogs.

The handle object passed to this function provides an interface for adding new catalogs and adding nested objects to the same archive (while checking for duplicates). See OutputArchiveHandle for more information.

Reimplemented in lsst::afw::typehandling::StorableHelper< Base >, lsst::afw::image::FilterLabel, lsst::meas::modelfit::Mixture, lsst::meas::algorithms::WarpedPsf, lsst::meas::algorithms::SingleGaussianPsf, lsst::meas::algorithms::KernelPsf, lsst::meas::algorithms::DoubleGaussianPsf, lsst::meas::algorithms::CoaddPsf, lsst::meas::algorithms::CoaddBoundedField, lsst::afw::math::WarpingControl, lsst::afw::math::NearestWarpingKernel, lsst::afw::math::BilinearWarpingKernel, lsst::afw::math::LanczosWarpingKernel, lsst::afw::math::TransformBoundedField, lsst::afw::math::ProductBoundedField, lsst::afw::math::PixelAreaBoundedField, lsst::afw::math::LinearCombinationKernel, lsst::afw::math::DeltaFunctionKernel, lsst::afw::math::AnalyticKernel, lsst::afw::math::FixedKernel, lsst::afw::math::ChebyshevBoundedField, lsst::afw::image::VisitInfo, lsst::afw::image::PhotoCalib, lsst::afw::image::CoaddInputs, lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >, lsst::afw::geom::Transform< afw::geom::Point2Endpoint, afw::geom::GenericEndpoint >, lsst::afw::geom::SkyWcs, lsst::afw::geom::polygon::Polygon, lsst::afw::detection::HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT >, lsst::afw::detection::GaussianPsf, lsst::afw::detection::Footprint, lsst::afw::cameraGeom::DetectorCollection, lsst::afw::cameraGeom::Camera, lsst::meas::extensions::psfex::PsfexPsf, lsst::afw::math::Chebyshev1Function2< ReturnT >, lsst::afw::math::PolynomialFunction2< ReturnT >, lsst::afw::math::DoubleGaussianFunction2< ReturnT >, and lsst::afw::math::GaussianFunction2< ReturnT >.

Definition at line 38 of file Persistable.cc.

38  {
39  assert(!isPersistable());
40  throw LSST_EXCEPT(pex::exceptions::LogicError,
41  "afw::table-based persistence is not supported for this object.");
42 }
virtual bool isPersistable() const noexcept
Return true if this particular object can be persisted using afw::table::io.
Definition: Persistable.h:102

◆ writeFits() [1/3]

void lsst::afw::table::io::Persistable::writeFits ( fits::Fits fitsfile) const
inherited

Write the object to an already-open FITS object.

Parameters
[in]fitsfileOpen FITS object to write to.

Definition at line 18 of file Persistable.cc.

18  {
19  OutputArchive archive;
20  archive.put(this);
21  archive.writeFits(fitsfile);
22 }

◆ writeFits() [2/3]

void lsst::afw::table::io::Persistable::writeFits ( fits::MemFileManager manager,
std::string const &  mode = "w" 
) const
inherited

Write the object to a FITS image in memory.

Parameters
[in]managerName of the file to write to.
[in]modeIf "w", any existing file with the given name will be overwritten. If "a", new HDUs will be appended to an existing file.

Definition at line 29 of file Persistable.cc.

29  {
30  fits::Fits fitsfile(manager, mode, fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK);
31  writeFits(fitsfile);
32 }
void writeFits(std::string const &fileName, std::string const &mode="w") const
Write the object to a regular FITS file.
Definition: Persistable.cc:24

◆ writeFits() [3/3]

void lsst::afw::table::io::Persistable::writeFits ( std::string const &  fileName,
std::string const &  mode = "w" 
) const
inherited

Write the object to a regular FITS file.

Parameters
[in]fileNameName of the file to write to.
[in]modeIf "w", any existing file with the given name will be overwritten. If "a", new HDUs will be appended to an existing file.

Definition at line 24 of file Persistable.cc.

24  {
25  fits::Fits fitsfile(fileName, mode, fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK);
26  writeFits(fitsfile);
27 }

Friends And Related Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream os,
Storable const &  storable 
)
related

Output operator for Storable.

Parameters
osthe desired output stream
storablethe object to print
Returns
a reference to os
Exceptions
UnsupportedOperationExceptionThrown if storable does not have an implementation of Storable::toString.

Definition at line 174 of file Storable.h.

174  {
175  return os << storable.toString();
176 }
std::ostream * os
Definition: Schema.cc:557

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