LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
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 { namespace afw { namespace table {
35 
36 class SimpleRecord;
37 class SimpleTable;
38 
46 class SimpleRecord : public BaseRecord {
47 public:
48 
49  typedef SimpleTable Table;
53 
55  return std::static_pointer_cast<SimpleTable const>(BaseRecord::getTable());
56  }
57 
59  RecordId getId() const;
61  void setId(RecordId id);
62 
63  IcrsCoord getCoord() const;
64  void setCoord(IcrsCoord const & coord);
65  void setCoord(Coord const & coord);
66 
67  Angle getRa() const;
68  void setRa(Angle ra);
69 
70  Angle getDec() const;
71  void setDec(Angle dec);
73 
74 protected:
75 
77 
78 };
79 
85 class SimpleTable : public BaseTable {
86 public:
87 
92 
103  static PTR(SimpleTable) make(Schema const & schema, PTR(IdFactory) const & idFactory);
104 
112  static PTR(SimpleTable) make(Schema const & schema) { return make(schema, IdFactory::makeSimple()); }
113 
123  r.disconnectAliases();
124  return r;
125  }
126 
133  static bool checkSchema(Schema const & other) {
134  return other.contains(getMinimalSchema().schema);
135  }
136 
139 
142 
145 
147 
152  static Key<RecordId> getIdKey() { return getMinimalSchema().id; }
157 
159  PTR(SimpleTable) clone() const { return std::static_pointer_cast<SimpleTable>(_clone()); }
160 
162  PTR(SimpleRecord) makeRecord() { return std::static_pointer_cast<SimpleRecord>(_makeRecord()); }
163 
166  return std::static_pointer_cast<SimpleRecord>(BaseTable::copyRecord(other));
167  }
168 
170  PTR(SimpleRecord) copyRecord(BaseRecord const & other, SchemaMapper const & mapper) {
171  return std::static_pointer_cast<SimpleRecord>(BaseTable::copyRecord(other, mapper));
172  }
173 
174 protected:
175 
176  SimpleTable(Schema const & schema, PTR(IdFactory) const & idFactory);
177 
178  SimpleTable(SimpleTable const & other);
179 
180 private:
181 
182  // Struct that holds the minimal schema and the special keys we've added to it.
183  struct MinimalSchema {
187 
188  MinimalSchema();
189  };
190 
191  // Return the singleton minimal schema.
192  static MinimalSchema & getMinimalSchema();
193 
194  friend class io::FitsWriter;
195 
196  // Return a writer object that knows how to save in FITS format. See also FitsWriter.
197  virtual PTR(io::FitsWriter) makeFitsWriter(fits::Fits * fitsfile, int flags) const;
198 
199  PTR(IdFactory) _idFactory; // generates IDs for new records
200 };
201 
202 #ifndef SWIG
203 
204 inline RecordId SimpleRecord::getId() const { return get(SimpleTable::getIdKey()); }
205 inline void SimpleRecord::setId(RecordId id) { set(SimpleTable::getIdKey(), id); }
206 
208 inline void SimpleRecord::setCoord(IcrsCoord const & coord) { set(SimpleTable::getCoordKey(), coord); }
209 inline void SimpleRecord::setCoord(Coord const & coord) { SimpleTable::getCoordKey().set(*this, coord); }
210 
211 inline Angle SimpleRecord::getRa() const { return get(SimpleTable::getCoordKey().getRa()); }
212 inline void SimpleRecord::setRa(Angle ra) { set(SimpleTable::getCoordKey().getRa(), ra); }
213 
214 inline Angle SimpleRecord::getDec() const { return get(SimpleTable::getCoordKey().getDec()); }
215 inline void SimpleRecord::setDec(Angle dec) { set(SimpleTable::getCoordKey().getDec(), dec); }
216 
217 #endif // !SWIG
218 
219 }}} // namespace lsst::afw::table
220 
221 #endif // !AFW_TABLE_Simple_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:44
int contains(Schema const &other, int flags=EQUAL_KEYS) const
Test whether the given schema is a subset of this.
void disconnectAliases()
Sever the connection between this schema and any others with which it shares aliases.
void setDec(Angle dec)
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:215
Key< geom::Angle > getDec() const
Return a constituent Key.
Definition: aggregates.h:171
Angle getDec() const
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:214
boost::shared_ptr< SimpleRecord > copyRecord(BaseRecord const &other)
Deep-copy a record, requiring that it have the same schema as this table.
Definition: Simple.h:165
Writer object for FITS binary tables.
Definition: FitsWriter.h:22
IcrsCoord getCoord() const
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:207
void setIdFactory(boost::shared_ptr< IdFactory > f)
Switch to a new IdFactory – object that generates IDs for the table (may be null).
Definition: Simple.h:144
static boost::shared_ptr< IdFactory > makeSimple()
Return a simple IdFactory that simply counts from 1.
SimpleRecord(boost::shared_ptr< SimpleTable > const &table)
static Schema makeMinimalSchema()
Return a minimal schema for Simple tables and records.
Definition: Simple.h:121
SortedCatalogT< Record const > ConstCatalog
Definition: Simple.h:91
afw::table::Schema schema
Definition: GaussianPsf.cc:41
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:19
ColumnViewT< SimpleRecord > ColumnView
Definition: Simple.h:89
void setId(RecordId id)
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:205
boost::shared_ptr< SimpleTable const > getTable() const
Definition: Simple.h:54
ColumnViewT< SimpleRecord > ColumnView
Definition: Simple.h:50
virtual boost::shared_ptr< io::FitsWriter > makeFitsWriter(fits::Fits *fitsfile, int flags) const
boost::shared_ptr< SimpleRecord > makeRecord()
Default-construct an associated record.
Definition: Simple.h:162
boost::shared_ptr< SimpleTable > clone() const
Return a polymorphic deep copy of the table.
Definition: Simple.h:159
static Key< RecordId > getIdKey()
Get keys for standard fields shared by all references.
Definition: Simple.h:153
boost::shared_ptr< IdFactory > getIdFactory()
Return the object that generates IDs for the table (may be null).
Definition: Simple.h:138
void setCoord(IcrsCoord const &coord)
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:208
SimpleTable(Schema const &schema, boost::shared_ptr< IdFactory > const &idFactory)
boost::shared_ptr< IdFactory > _idFactory
Definition: Simple.h:199
std::int64_t RecordId
Type used for unique IDs for records.
Definition: misc.h:20
static boost::shared_ptr< SimpleTable > make(Schema const &schema)
Construct a new table.
Definition: Simple.h:112
Table class that must contain a unique ID field and a celestial coordinate field. ...
Definition: Simple.h:85
A class representing an Angle.
Definition: Angle.h:103
static bool checkSchema(Schema const &other)
Return true if the given schema is a valid SimpleTable schema.
Definition: Simple.h:133
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:55
virtual void set(BaseRecord &record, coord::IcrsCoord const &value) const
Set an IcrsCoord in the given record.
std::map< Citizen const *, CitizenInfo > table
Definition: Citizen.h:90
SortedCatalogT< Record > Catalog
Definition: Simple.h:90
Angle getRa() const
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:211
virtual boost::shared_ptr< BaseTable > _clone() const =0
Clone implementation with noncovariant return types.
static MinimalSchema & getMinimalSchema()
Key< geom::Angle > getRa() const
Return a constituent Key.
Definition: aggregates.h:170
A polymorphic functor base class for generating record IDs for a table.
Definition: IdFactory.h:19
virtual boost::shared_ptr< BaseRecord > _makeRecord()=0
Default-construct an associated record (protected implementation).
static boost::shared_ptr< SimpleTable > make(Schema const &schema, boost::shared_ptr< IdFactory > const &idFactory)
Construct a new table.
RecordId getId() const
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:204
boost::shared_ptr< BaseTable const > getTable() const
Return the table this record is associated with.
Definition: BaseRecord.h:60
Base class for all records.
Definition: BaseRecord.h:27
#define PTR(...)
Definition: base.h:41
static CoordKey getCoordKey()
Key for the celestial coordinates.
Definition: Simple.h:155
boost::shared_ptr< BaseRecord > copyRecord(BaseRecord const &input)
Deep-copy a record, requiring that it have the same schema as this table.
SortedCatalogT< SimpleRecord > Catalog
Definition: Simple.h:51
SortedCatalogT< SimpleRecord const > ConstCatalog
Definition: Simple.h:52
#define CONST_PTR(...)
A shared pointer to a const object.
Definition: base.h:47
void setRa(Angle ra)
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:212
Record class that must contain a unique ID field and a celestial coordinate field.
Definition: Simple.h:46
This is the base class for spherical coordinates.
Definition: Coord.h:69
A class to handle Icrs coordinates (inherits from Coord)
Definition: Coord.h:156
Base class for all tables.
Definition: BaseTable.h:43
A FunctorKey used to get or set celestial coordinates from a pair of Angle keys.
Definition: aggregates.h:119