LSSTApplications  19.0.0-14-gb0260a2+1b4fc4249b,20.0.0+19029f0d82,20.0.0+66077e84be,20.0.0+b8df9e862d,20.0.0+e2e26847c2,20.0.0+e47e9b3a81,20.0.0-1-g253301a+19029f0d82,20.0.0-1-g2b7511a+46a6078777,20.0.0-1-g3dda6ea+905cef1a44,20.0.0-1-g4d801e7+5fcfd52d2e,20.0.0-1-g5b95a8c+19889959e1,20.0.0-1-gc96f8cb+d5e4df5959,20.0.0-1-gedffbd8+6ca2c30637,20.0.0-10-g0891cd99+caa8c2603a,20.0.0-13-gad96b2d30+614f89f815,20.0.0-17-gcdbda88+2b141d441d,20.0.0-2-g4dae9ad+d5e4df5959,20.0.0-2-g52fdb94+046030bafd,20.0.0-2-g61b8584+85c46248f3,20.0.0-2-g8177d33+f2ab36af31,20.0.0-2-gb780d76+f45b7d88f4,20.0.0-2-gf072044+19029f0d82,20.0.0-22-gdf434b7+d5e4df5959,20.0.0-23-g10eeb28+452d7a9290,20.0.0-23-g8900aa8+a8b4322b0e,20.0.0-3-g1653f94+85c46248f3,20.0.0-3-g4cc78c6+63636aeed8,20.0.0-3-g750bffe+7a989609f2,20.0.0-3-gbd60e8c+ff10c6d78d,20.0.0-33-g078e64d5+a2256d2c79,20.0.0-4-g97dc21a+a8b4322b0e,20.0.0-4-gfea843c+f45b7d88f4,20.0.0-5-g357b56b+f45b7d88f4,20.0.0-6-g9a5b7a1+3d4d12ed4e,20.0.0-61-g4de25fb+ddf3488217,20.0.0-7-gcda7bf1+dffc53c16b,w.2020.44
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) {}

◆ InputArchive() [4/4]

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

Definition at line 171 of file InputArchive.cc.

171 : InputArchive(other) {}

◆ ~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  {
61  std::shared_ptr<T> p = std::dynamic_pointer_cast<T>(get(id));
62  LSST_ARCHIVE_ASSERT(p || id == 0);
63  return p;
64  }

◆ 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 &&  other)

Definition at line 178 of file InputArchive.cc.

178 { return *this = other; }

◆ operator=() [2/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 }

◆ 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 }

The documentation for this class was generated from the following files:
std::string
STL class.
std::shared_ptr
STL class.
std::shared_ptr::get
T get(T... args)
lsst.pex.config.history.format
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
LSST_FITS_EXCEPT
#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
LSST_ARCHIVE_ASSERT
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
Definition: Persistable.h:48
other
ItemVariant const * other
Definition: Schema.cc:56
lsst::afw::table::io::InputArchive::InputArchive
InputArchive()
Construct an empty InputArchive that contains no objects.
Definition: InputArchive.cc:162
lsst::afw::table::CatalogT< BaseRecord >::readFits
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
lsst::afw::table::BaseCatalog
CatalogT< BaseRecord > BaseCatalog
Definition: fwd.h:71
lsst::afw::table::io::InputArchive::get
std::shared_ptr< Persistable > get(int id) const
Load the Persistable with the given ID and return it.
Definition: InputArchive.cc:182