LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
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 "boost/noncopyable.hpp"
6 
7 #include "lsst/base.h"
9 
10 namespace lsst { namespace afw { namespace table {
11 
12 class Schema;
13 class BaseRecord;
14 template <typename RecordT> class CatalogT;
15 typedef CatalogT<BaseRecord> BaseCatalog;
16 
17 namespace io {
18 
19 class Persistable;
20 class OutputArchiveHandle;
21 
34 public:
35 
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(CONST_PTR(Persistable) obj, bool permissive=false) { return put(obj.get(), permissive); }
76 
81  BaseCatalog const & getIndexCatalog() const;
82 
84  BaseCatalog const & getCatalog(int n) const;
85 
87  int countCatalogs() const;
88 
96  void writeFits(fits::Fits & fitsfile) const;
97 
98 private:
99 
100  class Impl;
101 
102  PTR(Impl) _impl;
103 };
104 
111 class OutputArchiveHandle : private boost::noncopyable {
112 public:
113 
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(CONST_PTR(Persistable) obj, bool permissive=false) { return put(obj.get(), permissive); }
139 
141 
142 private:
143 
144  friend class OutputArchive::Impl;
145 
147  int id, std::string const & name, std::string const & module,
148  PTR(OutputArchive::Impl) impl
149  );
150 
151  int _id;
153  std::string _name;
154  std::string _module;
155  PTR(OutputArchive::Impl) _impl;
156 };
157 
158 }}}} // namespace lsst::afw::table::io
159 
160 #endif // !AFW_TABLE_IO_OutputArchive_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:46
#define PTR(...)
Definition: base.h:41
table::Key< std::string > name
Definition: ApCorrMap.cc:71
CatalogT< BaseRecord > BaseCatalog
Definition: fwd.h:61
An object passed to Persistable::write to allow it to persist itself.
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...
A custom container class for records, based on std::vector.
Definition: Catalog.h:94
#define CONST_PTR(...)
Definition: base.h:47
int countCatalogs() const
Return the total number of catalogs, including the index.
void writeFits(fits::Fits &fitsfile) const
Write the archive to an already-open FITS object.
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:194
boost::shared_ptr< Impl > _impl
BaseCatalog const & getIndexCatalog() const
Return the index catalog that specifies where objects are stored in the data catalogs.
int put(boost::shared_ptr< Persistable const > obj, bool permissive=false)
Save a nested Persistable to the same archive.
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:33
int put(boost::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
OutputArchive()
Construct an empty OutputArchive containing no objects.
tbl::Schema schema
BaseCatalog const & getCatalog(int n) const
Return the nth catalog. Catalog 0 is always the index catalog.
OutputArchive & operator=(OutputArchive const &other)
Assign from another OutputArchive. Saved objects are not deep-copied.