LSST Applications g180d380827+107df2c2fa,g2079a07aa2+86d27d4dc4,g2305ad1205+27ad5d03fa,g2bbee38e9b+c6a8a0fb72,g337abbeb29+c6a8a0fb72,g33d1c0ed96+c6a8a0fb72,g3a166c0a6a+c6a8a0fb72,g3d1719c13e+cc4c7597ef,g487adcacf7+4b0be3ae0a,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+14d443d837,g62aa8f1a4b+588cc723a1,g674612935b+7a21c67e12,g858d7b2824+cc4c7597ef,g991b906543+cc4c7597ef,g99cad8db69+b90e8bab37,g9c22b2923f+e2510deafe,g9ddcbc5298+9a081db1e4,g9fbc5161f1+1dc7c5428e,ga1e77700b3+03d07e1c1f,gb0e22166c9+60f28cb32d,gb23b769143+cc4c7597ef,gba4ed39666+c2a2e4ac27,gbb8dafda3b+52e28152d7,gbd998247f1+585e252eca,gbeadb96d05+a322446fe6,gc120e1dc64+6a70fcc921,gc28159a63d+c6a8a0fb72,gc3e9b769f7+48c1343504,gcf0d15dbbd+7a21c67e12,gdaeeff99f8+f9a426f77a,ge6526c86ff+9349653ccd,ge79ae78c31+c6a8a0fb72,gee10cc3b42+585e252eca,w.2024.18
LSST Data Management Base Package
Loading...
Searching...
No Matches
Persistable.h
Go to the documentation of this file.
1// -*- lsst-c++ -*-
2#ifndef AFW_TABLE_IO_Persistable_h_INCLUDED
3#define AFW_TABLE_IO_Persistable_h_INCLUDED
4
5#include <climits>
6#include "lsst/base.h"
9
10namespace lsst {
11namespace afw {
12
13namespace fits {
14
15class Fits;
16class MemFileManager;
17
18} // namespace fits
19
20namespace table {
21namespace io {
22
23class InputArchive;
24class OutputArchive;
25class OutputArchiveHandle;
26class CatalogVector;
27
32
33
40
41
48#define LSST_ARCHIVE_ASSERT(EXPR) \
49 if (!(EXPR)) \
50 throw LSST_EXCEPT(lsst::afw::table::io::MalformedArchiveError, "Archive assertion failed: " #EXPR)
51
75public:
83 void writeFits(std::string const& fileName, std::string const& mode = "w") const;
84
92 void writeFits(fits::MemFileManager& manager, std::string const& mode = "w") const;
93
99 void writeFits(fits::Fits& fitsfile) const;
100
102 virtual bool isPersistable() const noexcept { return false; }
103
104 virtual ~Persistable() noexcept = default;
105
107 // convenient for derived classes not in afw::table::io
109
116
126
135
137
139 Persistable(Persistable&& other) noexcept = default;
140
141 Persistable& operator=(Persistable const& other) noexcept = default;
142 Persistable& operator=(Persistable&& other) noexcept = default;
143
144private:
147
148 template <typename T>
150
151 static std::shared_ptr<Persistable> _readFits(std::string const& fileName, int hdu = fits::DEFAULT_HDU);
152
153 static std::shared_ptr<Persistable> _readFits(fits::MemFileManager& manager, int hdu = fits::DEFAULT_HDU);
154
155 static std::shared_ptr<Persistable> _readFits(fits::Fits& fitsfile);
156};
157
175template <typename T>
177public:
184 return dynamicCast(Persistable::_readFits(fitsfile));
185 }
186
195 return dynamicCast(Persistable::_readFits(fileName, hdu));
196 }
197
206 return dynamicCast(Persistable::_readFits(manager, hdu));
207 }
208
218 static std::shared_ptr<T> dynamicCast(std::shared_ptr<Persistable> const &ptr);
219};
220
229protected:
230 using InputArchive = io::InputArchive; // convenient for derived classes not in afw::table::io
232
233public:
245 explicit PersistableFactory(std::string const& name);
246
249 CatalogVector const& catalogs) const = 0;
250
258 static PersistableFactory const& lookup(std::string const& name, std::string const& module = "");
259
260 virtual ~PersistableFactory() noexcept = default;
261
262 // No copying
265
266 // No moving
269};
270} // namespace io
271} // namespace table
272} // namespace afw
273} // namespace lsst
274
275#endif // !AFW_TABLE_IO_Persistable_h_INCLUDED
#define LSST_EXCEPTION_TYPE(t, b, c)
Macro used to define new types of exceptions without additional data.
Definition Exception.h:69
uint64_t * ptr
Definition RangeSet.cc:95
Basic LSST definitions.
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition fits.h:308
Lifetime-management for memory that goes into FITS memory files.
Definition fits.h:125
Tag types used to declare specialized field types.
Definition misc.h:31
A vector of catalogs used by Persistable.
A multi-catalog archive object used to load table::io::Persistable objects.
An exception thrown when an InputArchive's contents do not make sense.
Definition Persistable.h:39
An object passed to Persistable::write to allow it to persist itself.
A multi-catalog archive object used to save table::io::Persistable objects.
A CRTP facade class for subclasses of Persistable.
static std::shared_ptr< T > readFits(std::string const &fileName, int hdu=fits::DEFAULT_HDU)
Read an object from a regular FITS file.
static std::shared_ptr< T > readFits(fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU)
Read an object from a FITS file in memory.
static std::shared_ptr< T > readFits(fits::Fits &fitsfile)
Read an object from an already open FITS object.
A base class for factory classes used to reconstruct objects from records.
virtual std::shared_ptr< Persistable > read(InputArchive const &archive, CatalogVector const &catalogs) const =0
Construct a new object from the given InputArchive and vector of catalogs.
virtual ~PersistableFactory() noexcept=default
A base class for objects that can be persisted via afw::table::io Archive classes.
Definition Persistable.h:74
void writeFits(std::string const &fileName, std::string const &mode="w") const
Write the object to a regular FITS file.
virtual bool isPersistable() const noexcept
Return true if this particular object can be persisted using afw::table::io.
virtual std::string getPythonModule() const
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
virtual ~Persistable() noexcept=default
virtual std::string getPersistenceName() const
Return the unique name used to persist this object and look up its factory.
virtual void write(OutputArchiveHandle &handle) const
Write the object to one or more catalogs.
An exception thrown when problems occur during persistence.
Definition Persistable.h:31
Reports errors in external input/output operations.
Definition Runtime.h:160
const int DEFAULT_HDU
Specify that the default HDU should be read.
STL namespace.