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
OutputArchive.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 #ifndef AFW_TABLE_IO_OutputArchive_h_INCLUDED
3 #define AFW_TABLE_IO_OutputArchive_h_INCLUDED
4 
5 #include "lsst/base.h"
7 
8 namespace lsst {
9 namespace afw {
10 namespace table {
11 
12 class Schema;
13 class BaseRecord;
14 template <typename RecordT>
15 class CatalogT;
16 typedef CatalogT<BaseRecord> BaseCatalog;
17 
18 namespace io {
19 
20 class Persistable;
21 class OutputArchiveHandle;
22 
34 class OutputArchive final {
35 public:
36  friend class OutputArchiveHandle;
37 
39  OutputArchive();
40 
44 
48 
49  // (trivial) destructor must be defined in the source for pimpl idiom.
51 
53 
80  int put(std::shared_ptr<Persistable const> obj, bool permissive = false);
81  int put(Persistable const * obj, bool permissive = false);
82  int put(Persistable const & obj, bool permissive = false) { return put(&obj, permissive); }
84 
89  BaseCatalog const& getIndexCatalog() const;
90 
92  BaseCatalog const& getCatalog(int n) const;
93 
95  int countCatalogs() const;
96 
104  void writeFits(fits::Fits& fitsfile) const;
105 
106 private:
107  class Impl;
108 
109  std::shared_ptr<Impl> _impl;
110 };
111 
118 class OutputArchiveHandle final {
119 public:
126  BaseCatalog makeCatalog(Schema const& schema);
127 
132  void saveEmpty();
133 
140  void saveCatalog(BaseCatalog const& catalog);
141 
144  int put(Persistable const* obj, bool permissive = false);
145  int put(std::shared_ptr<Persistable const> obj, bool permissive = false);
146  int put(Persistable const & obj, bool permissive = false) { return put(&obj, permissive); }
148 
150 
151  // No copying
152  OutputArchiveHandle(const OutputArchiveHandle&) = delete;
154 
155  // No moving
158 
159 private:
160  friend class OutputArchive::Impl;
161 
162  OutputArchiveHandle(int id, std::string const& name, std::string const& module,
164 
165  int _id;
166  int _catPersistable;
167  std::string _name;
168  std::string _module;
170 };
171 } // namespace io
172 } // namespace table
173 } // namespace afw
174 } // namespace lsst
175 
176 #endif // !AFW_TABLE_IO_OutputArchive_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:50
int countCatalogs() const
Return the total number of catalogs, including the index.
Basic LSST definitions.
OutputArchive & operator=(OutputArchive const &other)
Assign from another OutputArchive. Saved objects are not deep-copied.
OutputArchive()
Construct an empty OutputArchive containing no objects.
CatalogT< BaseRecord > BaseCatalog
Definition: fwd.h:71
An object passed to Persistable::write to allow it to persist itself.
ItemVariant const * other
Definition: Schema.cc:56
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:297
BaseCatalog const & getIndexCatalog() const
Return the index catalog that specifies where objects are stored in the data catalogs.
STL class.
A base class for objects that can be persisted via afw::table::io Archive classes.
Definition: Persistable.h:74
A multi-catalog archive object used to save table::io::Persistable objects.
Definition: OutputArchive.h:34
void writeFits(fits::Fits &fitsfile) const
Write the archive to an already-open FITS object.
A base class for image defects.
table::Schema schema
Definition: Amplifier.cc:115
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 InputArc...
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 InputArc...
Definition: OutputArchive.h:82
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...
BaseCatalog const & getCatalog(int n) const
Return the nth catalog. Catalog 0 is always the index catalog.