lsst.afw  14.0-35-g29d3a87a7
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 
42  OutputArchive(OutputArchive const& other);
43 
45  OutputArchive& operator=(OutputArchive const& other);
46 
47  // (trivial) destructor must be defined in the source for pimpl idiom.
49 
51 
76  int put(Persistable const* obj, bool permissive = false);
77  int put(std::shared_ptr<Persistable const> obj, bool permissive = false) {
78  return put(obj.get(), permissive);
79  }
81 
86  BaseCatalog const& getIndexCatalog() const;
87 
89  BaseCatalog const& getCatalog(int n) const;
90 
92  int countCatalogs() const;
93 
101  void writeFits(fits::Fits& fitsfile) const;
102 
103 private:
104  class Impl;
105 
106  std::shared_ptr<Impl> _impl;
107 };
108 
116 public:
123  BaseCatalog makeCatalog(Schema const& schema);
124 
129  void saveEmpty();
130 
137  void saveCatalog(BaseCatalog const& catalog);
138 
140  int put(Persistable const* obj, bool permissive = false);
142  int put(std::shared_ptr<Persistable const> obj, bool permissive = false) {
143  return put(obj.get(), permissive);
144  }
146 
148 
149  // No copying
150  OutputArchiveHandle(const OutputArchiveHandle&) = delete;
152 
153  // No moving
156 
157 private:
158  friend class OutputArchive::Impl;
159 
160  OutputArchiveHandle(int id, std::string const& name, std::string const& module,
162 
163  int _id;
164  int _catPersistable;
166  std::string _module;
168 };
169 }
170 }
171 }
172 } // namespace lsst::afw::table::io
173 
174 #endif // !AFW_TABLE_IO_OutputArchive_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:47
int countCatalogs() const
Return the total number of catalogs, including the index.
BaseCatalog const & getCatalog(int n) const
Return the nth catalog. Catalog 0 is always the index catalog.
table::Key< std::string > name
Definition: ApCorrMap.cc:71
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:566
afw::table::Schema schema
Definition: GaussianPsf.cc:43
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:280
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:567
BaseCatalog const & getIndexCatalog() const
Return the index catalog that specifies where objects are stored in the data catalogs.
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...
OutputArchive & operator=(OutputArchive const &other)
Assign from another OutputArchive. Saved objects are not deep-copied.
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:77