lsst.afw  13.0-101-g894215678
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 
73  int put(Persistable const* obj, bool permissive = false);
74  int put(std::shared_ptr<Persistable const> obj, bool permissive = false) {
75  return put(obj.get(), permissive);
76  }
78 
83  BaseCatalog const& getIndexCatalog() const;
84 
86  BaseCatalog const& getCatalog(int n) const;
87 
89  int countCatalogs() const;
90 
98  void writeFits(fits::Fits& fitsfile) const;
99 
100 private:
101  class Impl;
102 
103  std::shared_ptr<Impl> _impl;
104 };
105 
113 public:
120  BaseCatalog makeCatalog(Schema const& schema);
121 
128  void saveCatalog(BaseCatalog const& catalog);
129 
131 
136  int put(Persistable const* obj, bool permissive = false);
137  int put(std::shared_ptr<Persistable const> obj, bool permissive = false) {
138  return put(obj.get(), permissive);
139  }
141 
143 
144  // No copying
145  OutputArchiveHandle(const OutputArchiveHandle&) = delete;
147 
148  // No moving
151 
152 private:
153  friend class OutputArchive::Impl;
154 
155  OutputArchiveHandle(int id, std::string const& name, std::string const& module,
156  std::shared_ptr<OutputArchive::Impl> impl);
157 
158  int _id;
159  int _catPersistable;
160  std::string _name;
161  std::string _module;
162  std::shared_ptr<OutputArchive::Impl> _impl;
163 };
164 }
165 }
166 }
167 } // namespace lsst::afw::table::io
168 
169 #endif // !AFW_TABLE_IO_OutputArchive_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:46
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:279
A base class for objects that can be persisted via afw::table::io Archive classes.
Definition: Persistable.h:73
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.
Definition: cameraGeom.dox:3
int _id
Definition: Mask.cc:567
BaseCatalog const & getIndexCatalog() const
Return the index catalog that specifies where objects are stored in the data catalogs.
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 a nested Persistable to the same archive.
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:74