LSST Applications g1653933729+a8ce1bb630,g171997e3ee+76e92115be,g1a997c3884+a8ce1bb630,g28da252d5a+4013ff5194,g2bbee38e9b+d6d0f9f6ae,g2bc492864f+d6d0f9f6ae,g2cdde0e794+ccb74358b7,g3156d2b45e+07302053f8,g347aa1857d+d6d0f9f6ae,g35bb328faa+a8ce1bb630,g3a166c0a6a+d6d0f9f6ae,g3e281a1b8c+130fae20e3,g4005a62e65+17cd334064,g414038480c+c9f68e2a12,g41af890bb2+3e1f62f438,g4e1a3235cc+9db7d56ad0,g7b55021d1b+7b623691d5,g80478fca09+334cc8d2bd,g82479be7b0+b568f6b267,g858d7b2824+37b39d8760,g9125e01d80+a8ce1bb630,ga5288a1d22+11cb34fefe,gae0086650b+a8ce1bb630,gb4ec7eb0ab+37b39d8760,gb58c049af0+d64f4d3760,gc081298178+284e133171,gc28159a63d+d6d0f9f6ae,gcf0d15dbbd+00fe2e0b07,gd6b7c0dfd1+8b62435e69,gda3e153d99+37b39d8760,gda6a2b7d83+00fe2e0b07,gdaeeff99f8+1711a396fd,gdd5a9049c5+23f3b3239a,ge2409df99d+5d9f551a54,ge33fd446bb+37b39d8760,ge79ae78c31+d6d0f9f6ae,gf0baf85859+2dea8344a2,gf5289d68f6+3777f3df5e,w.2024.41
LSST Data Management Base Package
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
lsst::afw::table::io::PersistableFacade< T > Class Template Reference

A CRTP facade class for subclasses of Persistable. More...

#include <Persistable.h>

Inheritance diagram for lsst::afw::table::io::PersistableFacade< T >:
lsst::afw::geom::Transform< afw::geom::Point2Endpoint, afw::geom::GenericEndpoint > lsst::afw::math::Function< Kernel::Pixel > lsst::afw::math::Function< Pixel > lsst::afw::math::Function< double > lsst::afw::math::Function1< Kernel::Pixel > lsst::afw::math::Function2< Pixel > lsst::afw::math::Function2< double > lsst::afw::detection::HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT >

Static Public Member Functions

static std::shared_ptr< T > readFits (fits::Fits &fitsfile)
 Read an object from an already open FITS object.
 
static std::shared_ptr< T > readFits (std::string const &fileName, int hdu=fits::DEFAULT_HDU)
 Read an object from a regular FITS file.
 
static std::shared_ptr< T > readFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU)
 Read an object from a FITS file in memory.
 
static std::shared_ptr< T > dynamicCast (std::shared_ptr< Persistable > const &ptr)
 Dynamically cast a shared_ptr.
 

Detailed Description

template<typename T>
class lsst::afw::table::io::PersistableFacade< T >

A CRTP facade class for subclasses of Persistable.

Derived classes should generally inherit from PersistableFacade at all levels, but only inherit from Persistable via the base class of each hierarchy. For example, with Psfs:

class Psf: public PersistableFacade<Psf>, public Persistable { ... };
class DoubleGaussianPsf: public PersistableFacade<DoubleGaussianPsf>, public Psf { ... };

Inheriting from PersistableFacade is not required for any classes but the base of each hierarchy, but doing so can save users from having to do some dynamic_casts.

Note
PersistableFacade should usually be the first class in a list of base classes; if it appears after a base class that inherits from different specialization of PersistableFacade, those base class member functions will hide the desired ones.

Definition at line 176 of file Persistable.h.

Member Function Documentation

◆ dynamicCast()

Dynamically cast a shared_ptr.

Dynamically cast a shared pointer and raise on failure.

You must provide an explicit template instantiation in the .cc file for each class that inherits from PersistableFacade. Designed to work around RTTI issues on macOS with hidden symbols;

Exceptions
lsst::pex::exceptions::LogicErrorif the cast fails

param[in] ptr The pointer to be cast.

Returns
The cast pointer.
Exceptions
lsst::pex::exceptions::TypeErrorIf the dynamic cast fails.

Definition at line 18 of file Persistable.cc.

18 {
19 auto result = std::dynamic_pointer_cast<T>(ptr);
20 if (!result) {
21 throw LSST_EXCEPT(pex::exceptions::TypeError, "Dynamic pointer cast failed");
22 }
23 return result;
24}
py::object result
Definition _schema.cc:429
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48
std::uint64_t * ptr
Definition RangeSet.cc:95

◆ readFits() [1/3]

template<typename T >
static std::shared_ptr< T > lsst::afw::table::io::PersistableFacade< T >::readFits ( fits::Fits & fitsfile)
inlinestatic

Read an object from an already open FITS object.

Parameters
[in]fitsfileFITS object to read from, already positioned at the desired HDU.

Definition at line 183 of file Persistable.h.

183 {
184 return dynamicCast(Persistable::_readFits(fitsfile));
185 }
static std::shared_ptr< T > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.

◆ readFits() [2/3]

template<typename T >
static std::shared_ptr< T > lsst::afw::table::io::PersistableFacade< T >::readFits ( fits::MemFileManager & manager,
int hdu = fits::DEFAULT_HDU )
inlinestatic

Read an object from a FITS file in memory.

Parameters
[in]managerManager for the memory to read from.
[in]hduHDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty.

Definition at line 205 of file Persistable.h.

205 {
206 return dynamicCast(Persistable::_readFits(manager, hdu));
207 }

◆ readFits() [3/3]

template<typename T >
static std::shared_ptr< T > lsst::afw::table::io::PersistableFacade< T >::readFits ( std::string const & fileName,
int hdu = fits::DEFAULT_HDU )
inlinestatic

Read an object from a regular FITS file.

Parameters
[in]fileNameName of the file to read.
[in]hduHDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty.

Definition at line 194 of file Persistable.h.

194 {
195 return dynamicCast(Persistable::_readFits(fileName, hdu));
196 }

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