LSST Applications g1653933729+a8ce1bb630,g171997e3ee+76e92115be,g1a997c3884+a8ce1bb630,g28da252d5a+4013ff5194,g2bbee38e9b+d6d0f9f6ae,g2bc492864f+d6d0f9f6ae,g2cdde0e794+ccb74358b7,g3156d2b45e+07302053f8,g347aa1857d+d6d0f9f6ae,g35bb328faa+a8ce1bb630,g3a166c0a6a+d6d0f9f6ae,g3e281a1b8c+130fae20e3,g4005a62e65+17cd334064,g414038480c+c9f68e2a12,g41af890bb2+3e1f62f438,g4e1a3235cc+9db7d56ad0,g7b55021d1b+7b623691d5,g80478fca09+334cc8d2bd,g82479be7b0+b568f6b267,g858d7b2824+37b39d8760,g9125e01d80+a8ce1bb630,ga5288a1d22+11cb34fefe,gae0086650b+a8ce1bb630,gb4ec7eb0ab+37b39d8760,gb58c049af0+d64f4d3760,gc081298178+284e133171,gc28159a63d+d6d0f9f6ae,gcf0d15dbbd+00fe2e0b07,gd6b7c0dfd1+8b62435e69,gda3e153d99+37b39d8760,gda6a2b7d83+00fe2e0b07,gdaeeff99f8+1711a396fd,gdd5a9049c5+23f3b3239a,ge2409df99d+5d9f551a54,ge33fd446bb+37b39d8760,ge79ae78c31+d6d0f9f6ae,gf0baf85859+2dea8344a2,gf5289d68f6+3777f3df5e,w.2024.41
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: