LSSTApplications  19.0.0-14-gb0260a2+6db932c395,20.0.0+235c3eae2c,20.0.0+448775ce90,20.0.0+5f56aa8f28,20.0.0+b40eaeb6a0,20.0.0+d006f05c5d,20.0.0+dbd2281351,20.0.0+dc1acf7baf,20.0.0+e2e26847c2,20.0.0+f48bb53858,20.0.0-1-g10df615+4b67200b40,20.0.0-1-g253301a+d006f05c5d,20.0.0-1-g2b7511a+f48bb53858,20.0.0-1-g4d801e7+68c50072dc,20.0.0-1-g5b95a8c+d1beabf16b,20.0.0-1-g660595b+f45b7d88f4,20.0.0-1-gc96f8cb+4df7bab894,20.0.0-1-gd1c87d7+add1f556b4,20.0.0-1-gedffbd8+eb23c4e4f2,20.0.0-11-g13aeee2+1a7c0f1887,20.0.0-14-g199c894+e853f797a7,20.0.0-15-gf5872d0+4df7bab894,20.0.0-16-g6fe20a1+b7072f60df,20.0.0-2-g4dae9ad+4df7bab894,20.0.0-2-g5ad0983+1a7c0f1887,20.0.0-2-g7818986+add1f556b4,20.0.0-2-gb095acb+63636aeed8,20.0.0-2-gdaeb0e8+7d7ca508c5,20.0.0-2-gec03fae+de92faa26f,20.0.0-23-g8d4de91b+950b69a445,20.0.0-4-gfea843c+f45b7d88f4,20.0.0-46-g00fa051+1467b54e00,20.0.0-5-g357b56b+f45b7d88f4,20.0.0-5-gfcebe35+a6a1a2f802,20.0.0-7-gc818c6e6+57cf537add,20.0.0-7-gcda7bf1+738fa57269,20.0.0-9-g61a2a9a3d+7fa50e000d,w.2020.38
LSSTDataManagementBasePackage
Classes | Public Member Functions | Friends | List of all members
lsst::afw::table::io::OutputArchive Class Referencefinal

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

#include <OutputArchive.h>

Classes

class  Impl
 

Public Member Functions

 OutputArchive ()
 Construct an empty OutputArchive containing no objects. More...
 
 OutputArchive (OutputArchive const &other)
 Copy-construct an OutputArchive. Saved objects are not deep-copied. More...
 
 OutputArchive (OutputArchive &&other)
 
OutputArchiveoperator= (OutputArchive const &other)
 Assign from another OutputArchive. Saved objects are not deep-copied. More...
 
OutputArchiveoperator= (OutputArchive &&other)
 
 ~OutputArchive ()
 
BaseCatalog const & getIndexCatalog () const
 Return the index catalog that specifies where objects are stored in the data catalogs. More...
 
BaseCatalog const & getCatalog (int n) const
 Return the nth catalog. Catalog 0 is always the index catalog. More...
 
int countCatalogs () const
 Return the total number of catalogs, including the index. More...
 
void writeFits (fits::Fits &fitsfile) const
 Write the archive to an already-open FITS object. More...
 
int put (std::shared_ptr< Persistable const > obj, bool permissive=false)
 Save an object to the archive and return a unique ID that can be used to retrieve it from an InputArchive. More...
 
int put (Persistable const *obj, bool permissive=false)
 Save an object to the archive and return a unique ID that can be used to retrieve it from an InputArchive. More...
 
int put (Persistable const &obj, bool permissive=false)
 Save an object to the archive and return a unique ID that can be used to retrieve it from an InputArchive. More...
 

Friends

class OutputArchiveHandle
 

Detailed Description

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

OutputArchive should generally be used directly only by objects that do not themselves inherit from Persistable, but contain many objects that do (such as Exposure). It provides an interface for adding objects to the archive (put()), transforming them into catalogs that can be retrieved directly or written to a FITS file. The first catalog is an index that indicates which rows of the subsequent catalogs correspond to each object.

See getIndexCatalog() for a more detailed description of the index.

Definition at line 34 of file OutputArchive.h.

Constructor & Destructor Documentation

◆ OutputArchive() [1/3]

lsst::afw::table::io::OutputArchive::OutputArchive ( )

Construct an empty OutputArchive containing no objects.

Definition at line 157 of file OutputArchive.cc.

157 : _impl(new Impl()) {}

◆ OutputArchive() [2/3]

lsst::afw::table::io::OutputArchive::OutputArchive ( OutputArchive const &  other)

Copy-construct an OutputArchive. Saved objects are not deep-copied.

Definition at line 159 of file OutputArchive.cc.

159 : _impl(other._impl) {}

◆ OutputArchive() [3/3]

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

Definition at line 161 of file OutputArchive.cc.

161 : OutputArchive(other) {}

◆ ~OutputArchive()

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

Member Function Documentation

◆ countCatalogs()

int lsst::afw::table::io::OutputArchive::countCatalogs ( ) const

Return the total number of catalogs, including the index.

Definition at line 201 of file OutputArchive.cc.

201 { return _impl->_catalogs.size() + 1; }

◆ getCatalog()

BaseCatalog const & lsst::afw::table::io::OutputArchive::getCatalog ( int  n) const

Return the nth catalog. Catalog 0 is always the index catalog.

Definition at line 190 of file OutputArchive.cc.

190  {
191  if (n == 0) return _impl->_index;
192  if (std::size_t(n) > _impl->_catalogs.size() || n < 0) {
193  throw LSST_EXCEPT(
194  pex::exceptions::LengthError,
195  (boost::format("Catalog number %d is out of range [0,%d]") % n % _impl->_catalogs.size())
196  .str());
197  }
198  return _impl->_catalogs[n - 1];
199 }

◆ getIndexCatalog()

BaseCatalog const & lsst::afw::table::io::OutputArchive::getIndexCatalog ( ) const

Return the index catalog that specifies where objects are stored in the data catalogs.

Definition at line 188 of file OutputArchive.cc.

188 { return _impl->_index; }

◆ operator=() [1/2]

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

Definition at line 168 of file OutputArchive.cc.

168 { return *this = other; }

◆ operator=() [2/2]

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

Assign from another OutputArchive. Saved objects are not deep-copied.

Definition at line 163 of file OutputArchive.cc.

163  {
164  _impl = other._impl;
165  return *this;
166 }

◆ put() [1/3]

int lsst::afw::table::io::OutputArchive::put ( Persistable const &  obj,
bool  permissive = false 
)
inline

Save an object to the archive and return a unique ID that can be used to retrieve it from an InputArchive.

If permissive is true and obj->isPersistable() is false, the object will not be saved but 0 will be returned instead of throwing an exception.

If the given pointer is null, the returned ID is always 0, which may be used to retrieve null pointers from an InputArchive.

It is expected that the shared_ptr form will usually be used, as Persistables are typically held by shared_ptr. We also provide a const reference overload for temporaries as well as a const raw pointer overload for temporaries that may be null.

If the shared_ptr form is used and the given pointer has already been saved, it will not be written again and the same ID will be returned as the first time it was saved.

Exception Safety\n Provides no exception safety for the archive itself - if
the object being saved (or any nested object) throws an exception, the archive may be in an inconsistent state and should not be saved. The objects being saved are never modified during persistence, even when exceptions are thrown.

Definition at line 82 of file OutputArchive.h.

82 { return put(&obj, permissive); }

◆ put() [2/3]

int lsst::afw::table::io::OutputArchive::put ( Persistable const *  obj,
bool  permissive = false 
)

Save an object to the archive and return a unique ID that can be used to retrieve it from an InputArchive.

If permissive is true and obj->isPersistable() is false, the object will not be saved but 0 will be returned instead of throwing an exception.

If the given pointer is null, the returned ID is always 0, which may be used to retrieve null pointers from an InputArchive.

It is expected that the shared_ptr form will usually be used, as Persistables are typically held by shared_ptr. We also provide a const reference overload for temporaries as well as a const raw pointer overload for temporaries that may be null.

If the shared_ptr form is used and the given pointer has already been saved, it will not be written again and the same ID will be returned as the first time it was saved.

Exception Safety\n Provides no exception safety for the archive itself - if
the object being saved (or any nested object) throws an exception, the archive may be in an inconsistent state and should not be saved. The objects being saved are never modified during persistence, even when exceptions are thrown.

Definition at line 172 of file OutputArchive.cc.

172  {
173  if (!_impl.unique()) { // copy on write
174  std::shared_ptr<Impl> tmp(new Impl(*_impl));
175  _impl.swap(tmp);
176  }
177  return _impl->put(obj, _impl, permissive);
178 }

◆ put() [3/3]

int lsst::afw::table::io::OutputArchive::put ( std::shared_ptr< Persistable const >  obj,
bool  permissive = false 
)

Save an object to the archive and return a unique ID that can be used to retrieve it from an InputArchive.

If permissive is true and obj->isPersistable() is false, the object will not be saved but 0 will be returned instead of throwing an exception.

If the given pointer is null, the returned ID is always 0, which may be used to retrieve null pointers from an InputArchive.

It is expected that the shared_ptr form will usually be used, as Persistables are typically held by shared_ptr. We also provide a const reference overload for temporaries as well as a const raw pointer overload for temporaries that may be null.

If the shared_ptr form is used and the given pointer has already been saved, it will not be written again and the same ID will be returned as the first time it was saved.

Exception Safety\n Provides no exception safety for the archive itself - if
the object being saved (or any nested object) throws an exception, the archive may be in an inconsistent state and should not be saved. The objects being saved are never modified during persistence, even when exceptions are thrown.

Definition at line 180 of file OutputArchive.cc.

180  {
181  if (!_impl.unique()) { // copy on write
182  std::shared_ptr<Impl> tmp(new Impl(*_impl));
183  _impl.swap(tmp);
184  }
185  return _impl->put(std::move(obj), _impl, permissive);
186 }

◆ writeFits()

void lsst::afw::table::io::OutputArchive::writeFits ( fits::Fits fitsfile) const

Write the archive to an already-open FITS object.

Always appends new HDUs.

Parameters
[in]fitsfileOpen FITS object to write to.

Definition at line 203 of file OutputArchive.cc.

203 { _impl->writeFits(fitsfile); }

Friends And Related Function Documentation

◆ OutputArchiveHandle

friend class OutputArchiveHandle
friend

Definition at line 36 of file OutputArchive.h.


The documentation for this class was generated from the following files:
std::shared_ptr
STL class.
std::move
T move(T... args)
lsst::afw::table::io::OutputArchive::put
int put(std::shared_ptr< Persistable const > obj, bool permissive=false)
Save an object to the archive and return a unique ID that can be used to retrieve it from an InputArc...
Definition: OutputArchive.cc:180
lsst.pex.config.history.format
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
other
ItemVariant const * other
Definition: Schema.cc:56
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
std::size_t
lsst::afw::table::io::OutputArchive::OutputArchive
OutputArchive()
Construct an empty OutputArchive containing no objects.
Definition: OutputArchive.cc:157