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
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
lsst::afw::table::io::InputArchive Class Referencefinal

A multi-catalog archive object used to load table::io::Persistable objects. More...

#include <InputArchive.h>

Classes

class  Impl
 

Public Types

using Map = std::map< int, std::shared_ptr< Persistable > >
 

Public Member Functions

 InputArchive ()
 Construct an empty InputArchive that contains no objects. More...
 
 InputArchive (BaseCatalog const &index, CatalogVector const &dataCatalogs)
 Construct an archive from catalogs. More...
 
 InputArchive (InputArchive const &other)
 Copy-constructor. Does not deep-copy loaded Persistables. More...
 
 InputArchive (InputArchive &&other)
 
InputArchiveoperator= (InputArchive const &other)
 Assignment. Does not deep-copy loaded Persistables. More...
 
InputArchiveoperator= (InputArchive &&other)
 
 ~InputArchive ()
 
std::shared_ptr< Persistableget (int id) const
 Load the Persistable with the given ID and return it. More...
 
template<typename T >
std::shared_ptr< T > get (int id) const
 Load an object of the given type and ID with error checking. More...
 
Map const & getAll () const
 Load and return all objects in the archive. More...
 

Static Public Member Functions

static InputArchive readFits (fits::Fits &fitsfile)
 Read an object from an already open FITS object. More...
 

Detailed Description

A multi-catalog archive object used to load table::io::Persistable objects.

An InputArchive can be constructed directly from the catalogs produced by OutputArchive, or more usefully, read from a multi-extension FITS file.

See also
OutputArchive

Definition at line 31 of file InputArchive.h.

Member Typedef Documentation

◆ Map

Definition at line 33 of file InputArchive.h.

Constructor & Destructor Documentation

◆ InputArchive() [1/4]

lsst::afw::table::io::InputArchive::InputArchive ( )

Construct an empty InputArchive that contains no objects.

Definition at line 162 of file InputArchive.cc.

162 : _impl(new Impl()) {}

◆ InputArchive() [2/4]

lsst::afw::table::io::InputArchive::InputArchive ( BaseCatalog const &  index,
CatalogVector const &  dataCatalogs 
)

Construct an archive from catalogs.

Definition at line 166 of file InputArchive.cc.

167  : _impl(new Impl(index, catalogs)) {}

◆ InputArchive() [3/4]

lsst::afw::table::io::InputArchive::InputArchive ( InputArchive const &  other)
default

Copy-constructor. Does not deep-copy loaded Persistables.

◆ InputArchive() [4/4]

lsst::afw::table::io::InputArchive::InputArchive ( InputArchive &&  other)

Definition at line 171 of file InputArchive.cc.

171 : InputArchive(other) {}
InputArchive()
Construct an empty InputArchive that contains no objects.

◆ ~InputArchive()

lsst::afw::table::io::InputArchive::~InputArchive ( )
default

Member Function Documentation

◆ get() [1/2]

std::shared_ptr< Persistable > lsst::afw::table::io::InputArchive::get ( int  id) const

Load the Persistable with the given ID and return it.

If the object has already been loaded once, the same instance will be returned again.

Definition at line 179 of file InputArchive.cc.

179 { return _impl->get(id, *this); }
std::shared_ptr< Persistable > get(int id, InputArchive const &self)
Definition: InputArchive.cc:40

◆ get() [2/2]

template<typename T >
std::shared_ptr<T> lsst::afw::table::io::InputArchive::get ( int  id) const
inline

Load an object of the given type and ID with error checking.

Definition at line 60 of file InputArchive.h.

60  {
61  std::shared_ptr<T> p = std::dynamic_pointer_cast<T>(get(id));
62  LSST_ARCHIVE_ASSERT(p || id == 0);
63  return p;
64  }
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
Definition: Persistable.h:48
std::shared_ptr< Persistable > get(int id) const
Load the Persistable with the given ID and return it.

◆ getAll()

InputArchive::Map const & lsst::afw::table::io::InputArchive::getAll ( ) const

Load and return all objects in the archive.

Definition at line 181 of file InputArchive.cc.

181 { return _impl->getAll(*this); }
Map const & getAll(InputArchive const &self)

◆ operator=() [1/2]

InputArchive & lsst::afw::table::io::InputArchive::operator= ( InputArchive &&  other)

Definition at line 175 of file InputArchive.cc.

175 { return *this = other; }

◆ operator=() [2/2]

InputArchive & lsst::afw::table::io::InputArchive::operator= ( InputArchive const &  other)
default

Assignment. Does not deep-copy loaded Persistables.

◆ readFits()

InputArchive lsst::afw::table::io::InputArchive::readFits ( fits::Fits fitsfile)
static

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

183  {
184  BaseCatalog index = BaseCatalog::readFits(fitsfile);
185  std::shared_ptr<daf::base::PropertyList> metadata = index.getTable()->popMetadata();
186  assert(metadata); // BaseCatalog::readFits should always read metadata, even if there's nothing there
187  if (metadata->get<std::string>("EXTTYPE") != "ARCHIVE_INDEX") {
188  throw LSST_FITS_EXCEPT(fits::FitsError, fitsfile,
189  boost::format("Wrong value for archive index EXTTYPE: '%s'") %
190  metadata->get<std::string>("EXTTYPE"));
191  }
192  int nCatalogs = metadata->get<int>("AR_NCAT");
193  CatalogVector catalogs;
194  catalogs.reserve(nCatalogs);
195  for (int n = 1; n < nCatalogs; ++n) {
196  fitsfile.setHdu(1, true); // increment HDU by one
197  catalogs.push_back(BaseCatalog::readFits(fitsfile));
198  metadata = catalogs.back().getTable()->popMetadata();
199  if (metadata->get<std::string>("EXTTYPE") != "ARCHIVE_DATA") {
200  throw LSST_FITS_EXCEPT(fits::FitsError, fitsfile,
201  boost::format("Wrong value for archive data EXTTYPE: '%s'") %
202  metadata->get<std::string>("EXTTYPE"));
203  }
204  if (metadata->get<int>("AR_CATN") != n) {
205  throw LSST_FITS_EXCEPT(
206  fits::FitsError, fitsfile,
207  boost::format("Incorrect order for archive catalogs: AR_CATN=%d found at position %d") %
208  metadata->get<int>("AR_CATN") % n);
209  }
210  }
211  std::shared_ptr<Impl> impl(new Impl(index, catalogs));
212  return InputArchive(impl);
213 }
static CatalogT readFits(std::string const &filename, int hdu=fits::DEFAULT_HDU, int flags=0)
Read a FITS binary table from a regular file.
Definition: Catalog.h:348
#define LSST_FITS_EXCEPT(type, fitsObj,...)
A FITS-related replacement for LSST_EXCEPT that takes an additional Fits object and uses makeErrorMes...
Definition: fits.h:105
T get(T... args)
CatalogT< BaseRecord > BaseCatalog
Definition: fwd.h:72
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

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