Template Class PersistableFacade

Class Documentation

template<typename T>
class PersistableFacade

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.

Public Static Functions

static std::shared_ptr<T> readFits(fits::Fits &fitsfile)

Read an object from an already open FITS object.

Parameters
  • [in] fitsfile: FITS object to read from, already positioned at the desired HDU.

static std::shared_ptr<T> readFits(std::string const &fileName, int hdu = fits::DEFAULT_HDU)

Read an object from a regular FITS file.

Parameters
  • [in] fileName: Name of the file to read.

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

static std::shared_ptr<T> readFits(fits::MemFileManager &manager, int hdu = fits::DEFAULT_HDU)

Read an object from a FITS file in memory.

Parameters
  • [in] manager: Manager for the memory to read from.

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

std::shared_ptr<T> dynamicCast(std::shared_ptr<Persistable> const &ptr)

Dynamically cast a shared_ptr

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;

Dynamically cast a shared pointer and raise on failure.

Exceptions
  • lsst::pex::exceptions::LogicError: if the cast fails

param[in] ptr The pointer to be cast.

Return

The cast pointer.

Exceptions
  • lsst::pex::exceptions::TypeError: If the dynamic cast fails.