LSST Applications 26.0.0,g0265f82a02+6660c170cc,g07994bdeae+30b05a742e,g0a0026dc87+17526d298f,g0a60f58ba1+17526d298f,g0e4bf8285c+96dd2c2ea9,g0ecae5effc+c266a536c8,g1e7d6db67d+6f7cb1f4bb,g26482f50c6+6346c0633c,g2bbee38e9b+6660c170cc,g2cc88a2952+0a4e78cd49,g3273194fdb+f6908454ef,g337abbeb29+6660c170cc,g337c41fc51+9a8f8f0815,g37c6e7c3d5+7bbafe9d37,g44018dc512+6660c170cc,g4a941329ef+4f7594a38e,g4c90b7bd52+5145c320d2,g58be5f913a+bea990ba40,g635b316a6c+8d6b3a3e56,g67924a670a+bfead8c487,g6ae5381d9b+81bc2a20b4,g93c4d6e787+26b17396bd,g98cecbdb62+ed2cb6d659,g98ffbb4407+81bc2a20b4,g9ddcbc5298+7f7571301f,ga1e77700b3+99e9273977,gae46bcf261+6660c170cc,gb2715bf1a1+17526d298f,gc86a011abf+17526d298f,gcf0d15dbbd+96dd2c2ea9,gdaeeff99f8+0d8dbea60f,gdb4ec4c597+6660c170cc,ge23793e450+96dd2c2ea9,gf041782ebf+171108ac67
LSST Data Management Base Package
Loading...
Searching...
No Matches
BaseTable.h
Go to the documentation of this file.
1// -*- lsst-c++ -*-
2#ifndef AFW_TABLE_BaseTable_h_INCLUDED
3#define AFW_TABLE_BaseTable_h_INCLUDED
4#include <memory>
5
6#include "lsst/base.h"
7#include "ndarray/Manager.h"
10
11namespace lsst {
12namespace afw {
13
14namespace fits {
15
16class Fits;
17
18} // namespace fits
19
20namespace table {
21
22namespace detail {
23
32struct RecordData {
33 void * data;
35 ndarray::Manager::Ptr manager;
36};
37
38} // namespace detail
39
61class BaseTable : public std::enable_shared_from_this<BaseTable> {
62public:
65
68
71
74
76 static int nRecordsPerBlock;
77
80
82 void setMetadata(std::shared_ptr<daf::base::PropertyList> const& metadata) { _metadata = metadata; }
83
87 _metadata.swap(tmp);
88 return tmp;
89 }
90
101
109
128
135
137 Schema getSchema() const { return _schema; }
138
151 void preallocate(std::size_t nRecords);
152
159
173
179 static Schema makeMinimalSchema();
180
181 // Tables are not assignable to prevent type slicing.
182 BaseTable& operator=(BaseTable const& other) = delete;
183 BaseTable& operator=(BaseTable&& other) = delete;
184
185 virtual ~BaseTable();
186
187protected:
188
203 // n.b. this is implemented in BaseRecord.h, as it requires the BaseRecord
204 // definition, and must go in a header.
205 template <typename RecordT, typename ...Args>
207
208 virtual void handleAliasChange(std::string const& alias) {}
209
211 virtual std::shared_ptr<BaseTable> _clone() const;
212
215
217 explicit BaseTable(Schema const& schema);
218
220 BaseTable(BaseTable const& other) : _schema(other._schema), _metadata(other._metadata) {
221 if (_metadata) _metadata = std::static_pointer_cast<daf::base::PropertyList>(_metadata->deepCopy());
222 }
223 // Delegate to copy-constructor for backwards compatibility
224 BaseTable(BaseTable&& other) : BaseTable(other) {}
225
226private:
227 friend class BaseRecord;
228 friend class io::FitsWriter;
229 friend class AliasMap;
230
231 // Obtain raw data pointers and their managing objects for a new record.
232 detail::RecordData _makeNewRecordData();
233
234 /*
235 * Called by BaseRecord dtor to notify the table when it is about to be destroyed.
236 *
237 * This could allow the table to reclaim that space, but that requires more bookkeeping than
238 * it's presently worth unless this was the most recently allocated record.
239 *
240 * The motivation for attempting to reclaim even some memory is not because we're paranoid
241 * about using every last bit of allocated memory efficiently - it's so we can keep
242 * records contiguous as much as possible to allow ColumnView to be used.
243 */
244 void _destroy(BaseRecord& record);
245
246 // Return a writer object that knows how to save in FITS format. See also FitsWriter.
247 virtual std::shared_ptr<io::FitsWriter> makeFitsWriter(fits::Fits* fitsfile, int flags) const;
248
249 // All these are definitely private, not protected - we don't want derived classes mucking with them.
250 Schema _schema; // schema that defines the table's fields
251 ndarray::Manager::Ptr _manager; // current memory block to use for new records
252 std::shared_ptr<daf::base::PropertyList> _metadata; // flexible metadata; may be null
253};
254
255} // namespace table
256} // namespace afw
257} // namespace lsst
258
259#endif // !AFW_TABLE_BaseTable_h_INCLUDED
SchemaMapper * mapper
table::Schema schema
Definition python.h:134
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
Mapping class that holds aliases for a Schema.
Definition AliasMap.h:36
Column-wise view into a sequence of records that have been allocated contiguously.
Base class for all records.
Definition BaseRecord.h:31
Base class for all tables.
Definition BaseTable.h:61
void setMetadata(std::shared_ptr< daf::base::PropertyList > const &metadata)
Set the flexible metadata associated with the table. May be null.
Definition BaseTable.h:82
virtual std::shared_ptr< BaseRecord > _makeRecord()
Default-construct an associated record (protected implementation).
Definition BaseTable.cc:148
BaseTable & operator=(BaseTable const &other)=delete
std::shared_ptr< daf::base::PropertyList > popMetadata()
Return the metadata and set the internal metadata to a null pointer.
Definition BaseTable.h:85
virtual std::shared_ptr< io::FitsWriter > makeFitsWriter(fits::Fits *fitsfile, int flags) const
Definition BaseTable.cc:140
Schema getSchema() const
Return the table's schema.
Definition BaseTable.h:137
void preallocate(std::size_t nRecords)
Allocate contiguous space for new records in advance.
Definition BaseTable.cc:110
std::shared_ptr< RecordT > constructRecord(Args &&...args)
Helper function that must be used by all _makeRecord overrides to actually construct records.
Definition BaseRecord.h:227
BaseTable & operator=(BaseTable &&other)=delete
std::shared_ptr< daf::base::PropertyList > getMetadata() const
Return the flexible metadata associated with the table. May be null.
Definition BaseTable.h:79
std::shared_ptr< BaseRecord > copyRecord(BaseRecord const &input)
Deep-copy a record, requiring that it have the same schema as this table.
Definition BaseTable.cc:128
BaseTable(BaseTable const &other)
Copy construct.
Definition BaseTable.h:220
std::shared_ptr< BaseTable > clone() const
Return a polymorphic deep copy of the table.
Definition BaseTable.h:100
std::size_t getBufferSize() const
Return the number of additional records space has been already been allocated for.
Definition BaseTable.cc:112
BaseTable(BaseTable &&other)
Definition BaseTable.h:224
static Schema makeMinimalSchema()
Return a minimal schema for Base tables and records.
Definition BaseTable.cc:124
static int nRecordsPerBlock
Number of records in each memory block.
Definition BaseTable.h:76
static std::shared_ptr< BaseTable > make(Schema const &schema)
Construct a new table.
Definition BaseTable.cc:120
virtual void handleAliasChange(std::string const &alias)
Definition BaseTable.h:208
virtual std::shared_ptr< BaseTable > _clone() const
Clone implementation with noncovariant return types.
Definition BaseTable.cc:144
std::shared_ptr< BaseRecord > makeRecord()
Default-construct an associated record.
Definition BaseTable.h:108
Defines the fields and offsets for a table.
Definition Schema.h:51
A mapping between the keys of two Schemas, used to copy data between them.
Writer object for FITS binary tables.
Definition FitsWriter.h:25
Helper struct that contains the information passed from BaseTable to BaseRecord at construction.
Definition BaseTable.h:32
ndarray::Manager::Ptr manager
Definition BaseTable.h:35
std::shared_ptr< BaseTable > table
Definition BaseTable.h:34