LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
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

typedef std::map< int, std::shared_ptr< Persistable > > Map
 

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)

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

Definition at line 169 of file InputArchive.cc.

169 : _impl(other._impl) {}
ItemVariant const * other
Definition: Schema.cc:56

◆ InputArchive() [4/4]

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

Definition at line 171 of file InputArchive.cc.

171 : InputArchive(other) {}
ItemVariant const * other
Definition: Schema.cc:56
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 182 of file InputArchive.cc.

182 { return _impl->get(id, *this); }

◆ 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  {
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
table::Key< int > id
Definition: Detector.cc:162
T dynamic_pointer_cast(T... args)

◆ getAll()

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

Load and return all objects in the archive.

Definition at line 184 of file InputArchive.cc.

184 { return _impl->getAll(*this); }

◆ operator=() [1/2]

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

Assignment. Does not deep-copy loaded Persistables.

Definition at line 173 of file InputArchive.cc.

173  {
174  _impl = other._impl;
175  return *this;
176 }
ItemVariant const * other
Definition: Schema.cc:56

◆ operator=() [2/2]

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

Definition at line 178 of file InputArchive.cc.

178 { return *this = other; }
ItemVariant const * other
Definition: Schema.cc:56

◆ 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 186 of file InputArchive.cc.

186  {
187  BaseCatalog index = BaseCatalog::readFits(fitsfile);
188  std::shared_ptr<daf::base::PropertyList> metadata = index.getTable()->popMetadata();
189  assert(metadata); // BaseCatalog::readFits should always read metadata, even if there's nothing there
190  if (metadata->get<std::string>("EXTTYPE") != "ARCHIVE_INDEX") {
191  throw LSST_FITS_EXCEPT(fits::FitsError, fitsfile,
192  boost::format("Wrong value for archive index EXTTYPE: '%s'") %
193  metadata->get<std::string>("EXTTYPE"));
194  }
195  int nCatalogs = metadata->get<int>("AR_NCAT");
196  CatalogVector catalogs;
197  catalogs.reserve(nCatalogs);
198  for (int n = 1; n < nCatalogs; ++n) {
199  fitsfile.setHdu(1, true); // increment HDU by one
200  catalogs.push_back(BaseCatalog::readFits(fitsfile));
201  metadata = catalogs.back().getTable()->popMetadata();
202  if (metadata->get<std::string>("EXTTYPE") != "ARCHIVE_DATA") {
203  throw LSST_FITS_EXCEPT(fits::FitsError, fitsfile,
204  boost::format("Wrong value for archive data EXTTYPE: '%s'") %
205  metadata->get<std::string>("EXTTYPE"));
206  }
207  if (metadata->get<int>("AR_CATN") != n) {
208  throw LSST_FITS_EXCEPT(
209  fits::FitsError, fitsfile,
210  boost::format("Incorrect order for archive catalogs: AR_CATN=%d found at position %d") %
211  metadata->get<int>("AR_CATN") % n);
212  }
213  }
214  std::shared_ptr<Impl> impl(new Impl(index, catalogs));
215  return InputArchive(impl);
216 }
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
CatalogT< BaseRecord > BaseCatalog
Definition: fwd.h:71
STL class.
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:343
InputArchive()
Construct an empty InputArchive that contains no objects.
T get(T... args)
#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

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