lsst.afw  16.0-12-gf08c31002
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 
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 
78  int put(Persistable const* obj, bool permissive = false);
79  int put(std::shared_ptr<Persistable const> obj, bool permissive = false) {
80  return put(obj.get(), permissive);
81  }
83 
88  BaseCatalog const& getIndexCatalog() const;
89 
91  BaseCatalog const& getCatalog(int n) const;
92 
94  int countCatalogs() const;
95 
103  void writeFits(fits::Fits& fitsfile) const;
104 
105 private:
106  class Impl;
107 
108  std::shared_ptr<Impl> _impl;
109 };
110 
118 public:
125  BaseCatalog makeCatalog(Schema const& schema);
126 
131  void saveEmpty();
132 
139  void saveCatalog(BaseCatalog const& catalog);
140 
142  int put(Persistable const* obj, bool permissive = false);
144  int put(std::shared_ptr<Persistable const> obj, bool permissive = false) {
145  return put(obj.get(), permissive);
146  }
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;
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.
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.
std::string const & _name
Definition: Mask.cc:569
afw::table::Schema schema
Definition: GaussianPsf.cc:43
ItemVariant const * other
Definition: Schema.cc:55
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:296
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.
int _id
Definition: Mask.cc:570
T get(T... args)
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(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...
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.h:79
BaseCatalog const & getCatalog(int n) const
Return the nth catalog. Catalog 0 is always the index catalog.