LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
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
table::Key< std::string > name
Definition: ApCorrMap.cc:71
boost::shared_ptr< Impl > _impl
OutputArchive()
Construct an empty OutputArchive containing no objects.
CatalogT< BaseRecord > BaseCatalog
Definition: fwd.h:61
An object passed to Persistable::write to allow it to persist itself.
A custom container class for records, based on std::vector.
Definition: Catalog.h:94
afw::table::Schema schema
Definition: GaussianPsf.cc:41
#define PTR(...)
Definition: base.h:41
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:194
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
void writeFits(fits::Fits &fitsfile) const
Write the archive to an already-open FITS object.
int countCatalogs() const
Return the total number of catalogs, including the index.
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...
#define CONST_PTR(...)
Definition: base.h:47
BaseCatalog const & getCatalog(int n) const
Return the nth catalog. Catalog 0 is always the index catalog.
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.
OutputArchive & operator=(OutputArchive const &other)
Assign from another OutputArchive. Saved objects are not deep-copied.