LSSTApplications  16.0-10-g0ee56ad+5,16.0-11-ga33d1f2+5,16.0-12-g3ef5c14+3,16.0-12-g71e5ef5+18,16.0-12-gbdf3636+3,16.0-13-g118c103+3,16.0-13-g8f68b0a+3,16.0-15-gbf5c1cb+4,16.0-16-gfd17674+3,16.0-17-g7c01f5c+3,16.0-18-g0a50484+1,16.0-20-ga20f992+8,16.0-21-g0e05fd4+6,16.0-21-g15e2d33+4,16.0-22-g62d8060+4,16.0-22-g847a80f+4,16.0-25-gf00d9b8+1,16.0-28-g3990c221+4,16.0-3-gf928089+3,16.0-32-g88a4f23+5,16.0-34-gd7987ad+3,16.0-37-gc7333cb+2,16.0-4-g10fc685+2,16.0-4-g18f3627+26,16.0-4-g5f3a788+26,16.0-5-gaf5c3d7+4,16.0-5-gcc1f4bb+1,16.0-6-g3b92700+4,16.0-6-g4412fcd+3,16.0-6-g7235603+4,16.0-69-g2562ce1b+2,16.0-8-g14ebd58+4,16.0-8-g2df868b+1,16.0-8-g4cec79c+6,16.0-8-gadf6c7a+1,16.0-8-gfc7ad86,16.0-82-g59ec2a54a+1,16.0-9-g5400cdc+2,16.0-9-ge6233d7+5,master-g2880f2d8cf+3,v17.0.rc1
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.
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