LSST Applications g02d81e74bb+86cf3d8bc9,g180d380827+7a4e862ed4,g2079a07aa2+86d27d4dc4,g2305ad1205+e1ca1c66fa,g29320951ab+012e1474a1,g295015adf3+341ea1ce94,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+c429d67c83,g48712c4677+f88676dd22,g487adcacf7+27e1e21933,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+b41db86c35,g5a732f18d5+53520f316c,g64a986408d+86cf3d8bc9,g858d7b2824+86cf3d8bc9,g8a8a8dda67+585e252eca,g99cad8db69+84912a7fdc,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+a2b54eae19,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+6681f309db,gc120e1dc64+f0fcc2f6d8,gc28159a63d+0e5473021a,gcf0d15dbbd+c429d67c83,gdaeeff99f8+f9a426f77a,ge6526c86ff+0433e6603d,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+86cf3d8bc9,w.2024.17
LSST Data Management Base Package
Loading...
Searching...
No Matches
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.
 
 InputArchive (BaseCatalog const &index, CatalogVector const &dataCatalogs)
 Construct an archive from catalogs.
 
 InputArchive (InputArchive const &other)
 Copy-constructor. Does not deep-copy loaded Persistables.
 
 InputArchive (InputArchive &&other)
 
InputArchiveoperator= (InputArchive const &other)
 Assignment. Does not deep-copy loaded Persistables.
 
InputArchiveoperator= (InputArchive &&other)
 
 ~InputArchive ()
 
std::shared_ptr< Persistableget (int id) const
 Load the Persistable with the given ID and return it.
 
template<typename T >
std::shared_ptr< T > get (int id) const
 Load an object of the given type and ID with error checking.
 
Map constgetAll () const
 Load and return all objects in the archive.
 

Static Public Member Functions

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

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)

◆ 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:347
#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)

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