LSSTApplications  16.0-11-g09ed895+2,16.0-11-g12e47bd,16.0-11-g9bb73b2+6,16.0-12-g5c924a4+6,16.0-14-g9a974b3+1,16.0-15-g1417920+1,16.0-15-gdd5ca33+1,16.0-16-gf0259e2,16.0-17-g31abd91+7,16.0-17-g7d7456e+7,16.0-17-ga3d2e9f+13,16.0-18-ga4d4bcb+1,16.0-18-gd06566c+1,16.0-2-g0febb12+21,16.0-2-g9d5294e+69,16.0-2-ga8830df+6,16.0-20-g21842373+7,16.0-24-g3eae5ec,16.0-28-gfc9ea6c+4,16.0-29-ge8801f9,16.0-3-ge00e371+34,16.0-4-g18f3627+13,16.0-4-g5f3a788+20,16.0-4-ga3eb747+10,16.0-4-gabf74b7+29,16.0-4-gb13d127+6,16.0-49-g42e581f7+6,16.0-5-g27fb78a+7,16.0-5-g6a53317+34,16.0-5-gb3f8a4b+87,16.0-6-g9321be7+4,16.0-6-gcbc7b31+42,16.0-6-gf49912c+29,16.0-7-gd2eeba5+51,16.0-71-ge89f8615e,16.0-8-g21fd5fe+29,16.0-8-g3a9f023+20,16.0-8-g4734f7a+1,16.0-8-g5858431+3,16.0-9-gf5c1f43+8,master-gd73dc1d098+1,w.2019.01
LSSTDataManagementBasePackage
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 
29 #include "lsst/afw/table/Catalog.h"
33 
34 namespace lsst {
35 namespace afw {
36 namespace table {
37 
38 class SimpleRecord;
39 class SimpleTable;
40 
48 class SimpleRecord : public BaseRecord {
49 public:
50  typedef SimpleTable Table;
54 
57  }
58 
60  RecordId getId() const;
62  void setId(RecordId id);
63 
65  void setCoord(lsst::geom::SpherePoint const& coord);
66 
67  lsst::geom::Angle getRa() const;
68  void setRa(lsst::geom::Angle ra);
69 
70  lsst::geom::Angle getDec() const;
73 
74  SimpleRecord(const SimpleRecord&) = delete;
75  SimpleRecord& operator=(const SimpleRecord&) = delete;
76  SimpleRecord(SimpleRecord&&) = delete;
77  SimpleRecord& operator=(SimpleRecord&&) = delete;
78  ~SimpleRecord() override;
79 
80 protected:
81  friend class SimpleTable;
82 
84 };
85 
91 class SimpleTable : public BaseTable {
92 public:
97 
108  static std::shared_ptr<SimpleTable> make(Schema const& schema,
110 
119  return make(schema, IdFactory::makeSimple());
120  }
121 
130  Schema r = getMinimalSchema().schema;
131  r.disconnectAliases();
132  return r;
133  }
134 
141  static bool checkSchema(Schema const& other) { return other.contains(getMinimalSchema().schema); }
142 
144  std::shared_ptr<IdFactory> getIdFactory() { return _idFactory; }
145 
147  std::shared_ptr<IdFactory const> getIdFactory() const { return _idFactory; }
148 
150  void setIdFactory(std::shared_ptr<IdFactory> f) { _idFactory = f; }
151 
153 
158  static Key<RecordId> getIdKey() { return getMinimalSchema().id; }
161  static CoordKey getCoordKey() { return getMinimalSchema().coord; }
163 
166 
169  return std::static_pointer_cast<SimpleRecord>(_makeRecord());
170  }
171 
175  }
176 
180  }
181 
182  SimpleTable& operator=(SimpleTable const&) = delete;
183  SimpleTable& operator=(SimpleTable&&) = delete;
184  ~SimpleTable() override;
185 
186 protected:
188 
189  explicit SimpleTable(SimpleTable const& other);
190  explicit SimpleTable(SimpleTable&& other);
191 
192  std::shared_ptr<BaseTable> _clone() const override;
193 
194  std::shared_ptr<BaseRecord> _makeRecord() override;
195 
196 private:
197  // Struct that holds the minimal schema and the special keys we've added to it.
198  struct MinimalSchema {
199  Schema schema;
201  CoordKey coord;
202 
203  MinimalSchema();
204  };
205 
206  // Return the singleton minimal schema.
207  static MinimalSchema& getMinimalSchema();
208 
209  friend class io::FitsWriter;
210 
211  // Return a writer object that knows how to save in FITS format. See also FitsWriter.
212  std::shared_ptr<io::FitsWriter> makeFitsWriter(fits::Fits* fitsfile, int flags) const override;
213 
214  std::shared_ptr<IdFactory> _idFactory; // generates IDs for new records
215 };
216 
217 inline RecordId SimpleRecord::getId() const { return get(SimpleTable::getIdKey()); }
219 
222  set(SimpleTable::getCoordKey(), coord);
223 }
224 
227 
230 } // namespace table
231 } // namespace afw
232 } // namespace lsst
233 
234 #endif // !AFW_TABLE_Simple_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:50
Writer object for FITS binary tables.
Definition: FitsWriter.h:25
static Schema makeMinimalSchema()
Return a minimal schema for Simple tables and records.
Definition: Simple.h:129
RecordId getId() const
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:217
static bool checkSchema(Schema const &other)
Return true if the given schema is a valid SimpleTable schema.
Definition: Simple.h:141
Key< lsst::geom::Angle > getRa() const noexcept
Return a constituent Key.
Definition: aggregates.h:267
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:21
SortedCatalogT< Record const > ConstCatalog
Definition: Simple.h:96
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:178
static Key< RecordId > getIdKey()
Get keys for standard fields shared by all references.
Definition: Simple.h:159
void disconnectAliases()
Sever the connection between this schema and any others with which it shares aliases.
Definition: Schema.cc:729
Key< lsst::geom::Angle > getDec() const noexcept
Return a constituent Key.
Definition: aggregates.h:268
table::Key< int > id
Definition: Detector.cc:163
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:296
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:125
lsst::geom::SpherePoint getCoord() const
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:220
STL class.
double dec
Definition: Match.cc:41
A class representing an angle.
Definition: Angle.h:127
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:150
SortedCatalogT< Record > Catalog
Definition: Simple.h:95
Table class that must contain a unique ID field and a celestial coordinate field. ...
Definition: Simple.h:91
A base class for image defects.
Definition: cameraGeom.dox:3
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
Definition: fwd.h:63
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:173
int contains(Schema const &other, int flags=EQUAL_KEYS) const
Test whether the given schema is a subset of this.
Definition: Schema.cc:679
std::shared_ptr< IdFactory const > getIdFactory() const
Return the object that generates IDs for the table (may be null).
Definition: Simple.h:147
table::Schema schema
Definition: Camera.cc:161
T static_pointer_cast(T... args)
ColumnViewT< SimpleRecord > ColumnView
Definition: Simple.h:51
ColumnViewT< SimpleRecord > ColumnView
Definition: Simple.h:94
SimpleRecord & operator=(const SimpleRecord &)=delete
lsst::geom::Angle getDec() const
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:228
std::shared_ptr< BaseTable const > getTable() const
Return the table this record is associated with.
Definition: BaseRecord.h:57
std::shared_ptr< SimpleTable const > getTable() const
Definition: Simple.h:55
SortedCatalogT< SimpleRecord > Catalog
Definition: Simple.h:52
Base class for all records.
Definition: BaseRecord.h:31
std::shared_ptr< SimpleTable > clone() const
Return a polymorphic deep copy of the table.
Definition: Simple.h:165
Point in an unspecified spherical coordinate system.
Definition: SpherePoint.h:57
A class used as a handle to a particular field in a table.
Definition: fwd.h:45
std::shared_ptr< SimpleRecord > makeRecord()
Default-construct an associated record.
Definition: Simple.h:168
ItemVariant const * other
Definition: Schema.cc:56
static std::shared_ptr< IdFactory > makeSimple()
Return a simple IdFactory that simply counts from 1.
Definition: IdFactory.cc:70
friend class SimpleTable
Definition: Simple.h:81
Record class that must contain a unique ID field and a celestial coordinate field.
Definition: Simple.h:48
void setId(RecordId id)
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:218
void setCoord(lsst::geom::SpherePoint const &coord)
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:221
static CoordKey getCoordKey()
Key for the celestial coordinates.
Definition: Simple.h:161
std::shared_ptr< IdFactory > getIdFactory()
Return the object that generates IDs for the table (may be null).
Definition: Simple.h:144
void setRa(lsst::geom::Angle ra)
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:226
lsst::geom::Angle getRa() const
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:225
SortedCatalogT< SimpleRecord const > ConstCatalog
Definition: Simple.h:53
Base class for all tables.
Definition: BaseTable.h:44
SchemaMapper * mapper
Definition: SchemaMapper.cc:78
SimpleRecord(const SimpleRecord &)=delete
A FunctorKey used to get or set celestial coordinates from a pair of lsst::geom::Angle keys...
Definition: aggregates.h:210
void setDec(lsst::geom::Angle dec)
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:229
static std::shared_ptr< SimpleTable > make(Schema const &schema)
Construct a new table.
Definition: Simple.h:118