LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
Simple.h
Go to the documentation of this file.
1// -*- lsst-c++ -*-
2/*
3 * LSST Data Management System
4 * Copyright 2008, 2009, 2010, 2011 LSST Corporation.
5 *
6 * This product includes software developed by the
7 * LSST Project (http://www.lsst.org/).
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the LSST License Statement and
20 * the GNU General Public License along with this program. If not,
21 * see <http://www.lsstcorp.org/LegalNotices/>.
22 */
23#ifndef AFW_TABLE_Simple_h_INCLUDED
24#define AFW_TABLE_Simple_h_INCLUDED
25
33
34namespace lsst {
35namespace afw {
36namespace table {
37
38class SimpleRecord;
39class SimpleTable;
40
48class SimpleRecord : public BaseRecord {
49public:
54
65 BaseRecord(token, std::move(data))
66 {}
67
69 return std::static_pointer_cast<SimpleTable const>(BaseRecord::getTable());
70 }
71
73
74 RecordId getId() const;
75 void setId(RecordId id);
76
78 void setCoord(lsst::geom::SpherePoint const& coord);
79
81 void setRa(lsst::geom::Angle ra);
82
86
87 SimpleRecord(const SimpleRecord&) = delete;
91 ~SimpleRecord() override;
92
93private:
94 friend class SimpleTable;
95};
96
102class SimpleTable : public BaseTable {
103public:
108
120 std::shared_ptr<IdFactory> const& idFactory);
121
131 }
132
141 Schema r = getMinimalSchema().schema;
143 return r;
144 }
145
152 static bool checkSchema(Schema const& other) { return other.contains(getMinimalSchema().schema); }
153
156
158 std::shared_ptr<IdFactory const> getIdFactory() const { return _idFactory; }
159
161 void setIdFactory(std::shared_ptr<IdFactory> f) { _idFactory = f; }
162
164
170 static Key<RecordId> getIdKey() { return getMinimalSchema().id; }
172 static CoordKey getCoordKey() { return getMinimalSchema().coord; }
174
176 std::shared_ptr<SimpleTable> clone() const { return std::static_pointer_cast<SimpleTable>(_clone()); }
177
180 return std::static_pointer_cast<SimpleRecord>(_makeRecord());
181 }
182
185 return std::static_pointer_cast<SimpleRecord>(BaseTable::copyRecord(other));
186 }
187
190 return std::static_pointer_cast<SimpleRecord>(BaseTable::copyRecord(other, mapper));
191 }
192
195 ~SimpleTable() override;
196
197protected:
198 SimpleTable(Schema const& schema, std::shared_ptr<IdFactory> const& idFactory);
199
200 explicit SimpleTable(SimpleTable const& other);
201 explicit SimpleTable(SimpleTable&& other);
202
203 std::shared_ptr<BaseTable> _clone() const override;
204
206
207private:
208 // Struct that holds the minimal schema and the special keys we've added to it.
209 struct MinimalSchema {
212 CoordKey coord;
213
214 MinimalSchema();
215 };
216
217 // Return the singleton minimal schema.
218 static MinimalSchema& getMinimalSchema();
219
220 friend class io::FitsWriter;
221
222 // Return a writer object that knows how to save in FITS format. See also FitsWriter.
223 std::shared_ptr<io::FitsWriter> makeFitsWriter(fits::Fits* fitsfile, int flags) const override;
224
225 std::shared_ptr<IdFactory> _idFactory; // generates IDs for new records
226};
227
230
234}
235
238
241} // namespace table
242} // namespace afw
243} // namespace lsst
244
245#endif // !AFW_TABLE_Simple_h_INCLUDED
char * data
Definition: BaseRecord.cc:61
table::Key< int > id
Definition: Detector.cc:162
double dec
Definition: Match.cc:41
SchemaMapper * mapper
Definition: SchemaMapper.cc:71
table::Schema schema
Definition: python.h:134
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:297
Column-wise view into a sequence of records that have been allocated contiguously.
Base class for all records.
Definition: BaseRecord.h:31
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
Definition: BaseRecord.h:151
std::shared_ptr< BaseTable const > getTable() const
Return the table this record is associated with.
Definition: BaseRecord.h:83
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
Definition: BaseRecord.h:164
Base class for all tables.
Definition: BaseTable.h:61
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
A FunctorKey used to get or set celestial coordinates from a pair of lsst::geom::Angle keys.
Definition: aggregates.h:210
static std::shared_ptr< IdFactory > makeSimple()
Return a simple IdFactory that simply counts from 1.
Definition: IdFactory.cc:70
A class used as a handle to a particular field in a table.
Definition: Key.h:53
Defines the fields and offsets for a table.
Definition: Schema.h:51
void disconnectAliases()
Sever the connection between this schema and any others with which it shares aliases.
Definition: Schema.cc:540
int contains(Schema const &other, int flags=EQUAL_KEYS) const
Test whether the given schema is a subset of this.
Definition: Schema.cc:490
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:21
Record class that must contain a unique ID field and a celestial coordinate field.
Definition: Simple.h:48
lsst::geom::Angle getRa() const
Definition: Simple.h:236
void setCoord(lsst::geom::SpherePoint const &coord)
Definition: Simple.h:232
SimpleRecord(SimpleRecord &&)=delete
RecordId getId() const
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:228
std::shared_ptr< SimpleTable const > getTable() const
Definition: Simple.h:68
lsst::geom::SpherePoint getCoord() const
Definition: Simple.h:231
SimpleRecord(const SimpleRecord &)=delete
void setId(RecordId id)
Definition: Simple.h:229
void setRa(lsst::geom::Angle ra)
Definition: Simple.h:237
SimpleRecord & operator=(const SimpleRecord &)=delete
void setDec(lsst::geom::Angle dec)
Definition: Simple.h:240
friend class SimpleTable
Definition: Simple.h:94
SimpleRecord(ConstructionToken const &token, detail::RecordData &&data)
Constructor used by SimpleTable.
Definition: Simple.h:64
SimpleRecord & operator=(SimpleRecord &&)=delete
lsst::geom::Angle getDec() const
Definition: Simple.h:239
Table class that must contain a unique ID field and a celestial coordinate field.
Definition: Simple.h:102
static std::shared_ptr< SimpleTable > make(Schema const &schema)
Construct a new table.
Definition: Simple.h:129
SimpleTable & operator=(SimpleTable const &)=delete
std::shared_ptr< SimpleTable > clone() const
Return a polymorphic deep copy of the table.
Definition: Simple.h:176
static Key< RecordId > getIdKey()
Get keys for standard fields shared by all references.
Definition: Simple.h:170
static bool checkSchema(Schema const &other)
Return true if the given schema is a valid SimpleTable schema.
Definition: Simple.h:152
std::shared_ptr< BaseTable > _clone() const override
Clone implementation with noncovariant return types.
Definition: Simple.cc:108
static Schema makeMinimalSchema()
Return a minimal schema for Simple tables and records.
Definition: Simple.h:140
std::shared_ptr< BaseRecord > _makeRecord() override
Default-construct an associated record (protected implementation).
Definition: Simple.cc:112
static CoordKey getCoordKey()
Key for the celestial coordinates.
Definition: Simple.h:172
std::shared_ptr< IdFactory > getIdFactory()
Return the object that generates IDs for the table (may be null).
Definition: Simple.h:155
void setIdFactory(std::shared_ptr< IdFactory > f)
Switch to a new IdFactory – object that generates IDs for the table (may be null).
Definition: Simple.h:161
static std::shared_ptr< SimpleTable > make(Schema const &schema, std::shared_ptr< IdFactory > const &idFactory)
Construct a new table.
Definition: Simple.cc:75
std::shared_ptr< IdFactory const > getIdFactory() const
Return the object that generates IDs for the table (may be null).
Definition: Simple.h:158
std::shared_ptr< SimpleRecord > copyRecord(BaseRecord const &other)
Deep-copy a record, requiring that it have the same schema as this table.
Definition: Simple.h:184
std::shared_ptr< SimpleRecord > makeRecord()
Default-construct an associated record.
Definition: Simple.h:179
std::shared_ptr< SimpleRecord > copyRecord(BaseRecord const &other, SchemaMapper const &mapper)
Deep-copy a record, requiring that it have the same schema as this table.
Definition: Simple.h:189
SimpleTable(Schema const &schema, std::shared_ptr< IdFactory > const &idFactory)
Definition: Simple.cc:84
SimpleTable & operator=(SimpleTable &&)=delete
Custom catalog class for record/table subclasses that are guaranteed to have an ID,...
Definition: SortedCatalog.h:42
Writer object for FITS binary tables.
Definition: FitsWriter.h:25
A class representing an angle.
Definition: Angle.h:128
Point in an unspecified spherical coordinate system.
Definition: SpherePoint.h:57
A base class for image defects.
STL namespace.
Helper struct that contains the information passed from BaseTable to BaseRecord at construction.
Definition: BaseTable.h:32