LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
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"
32 
33 namespace lsst { namespace afw { namespace table {
34 
35 class SimpleRecord;
36 class SimpleTable;
37 
45 class SimpleRecord : public BaseRecord {
46 public:
47 
48  typedef SimpleTable Table;
52 
54  return boost::static_pointer_cast<SimpleTable const>(BaseRecord::getTable());
55  }
56 
58  RecordId getId() const;
60  void setId(RecordId id);
61 
62  IcrsCoord getCoord() const;
63  void setCoord(IcrsCoord const & coord);
64  void setCoord(Coord const & coord);
65 
66  Angle getRa() const;
67  void setRa(Angle ra);
68 
69  Angle getDec() const;
70  void setDec(Angle dec);
72 
73 protected:
74 
76 
77 };
78 
84 class SimpleTable : public BaseTable {
85 public:
86 
91 
102  static PTR(SimpleTable) make(Schema const & schema, PTR(IdFactory) const & idFactory);
103 
111  static PTR(SimpleTable) make(Schema const & schema) { return make(schema, IdFactory::makeSimple()); }
112 
122  r.disconnectAliases();
123  return r;
124  }
125 
132  static bool checkSchema(Schema const & other) {
133  return other.contains(getMinimalSchema().schema);
134  }
135 
138 
141 
144 
146 
151  static Key<RecordId> getIdKey() { return getMinimalSchema().id; }
156 
158  PTR(SimpleTable) clone() const { return boost::static_pointer_cast<SimpleTable>(_clone()); }
159 
161  PTR(SimpleRecord) makeRecord() { return boost::static_pointer_cast<SimpleRecord>(_makeRecord()); }
162 
165  return boost::static_pointer_cast<SimpleRecord>(BaseTable::copyRecord(other));
166  }
167 
169  PTR(SimpleRecord) copyRecord(BaseRecord const & other, SchemaMapper const & mapper) {
170  return boost::static_pointer_cast<SimpleRecord>(BaseTable::copyRecord(other, mapper));
171  }
172 
173 protected:
174 
175  SimpleTable(Schema const & schema, PTR(IdFactory) const & idFactory);
176 
177  SimpleTable(SimpleTable const & other);
178 
179 private:
180 
181  // Struct that holds the minimal schema and the special keys we've added to it.
182  struct MinimalSchema {
186 
187  MinimalSchema();
188  };
189 
190  // Return the singleton minimal schema.
191  static MinimalSchema & getMinimalSchema();
192 
193  friend class io::FitsWriter;
194 
195  // Return a writer object that knows how to save in FITS format. See also FitsWriter.
196  virtual PTR(io::FitsWriter) makeFitsWriter(fits::Fits * fitsfile, int flags) const;
197 
198  PTR(IdFactory) _idFactory; // generates IDs for new records
199 };
200 
201 #ifndef SWIG
202 
203 inline RecordId SimpleRecord::getId() const { return get(SimpleTable::getIdKey()); }
204 inline void SimpleRecord::setId(RecordId id) { set(SimpleTable::getIdKey(), id); }
205 
207 inline void SimpleRecord::setCoord(IcrsCoord const & coord) { set(SimpleTable::getCoordKey(), coord); }
208 inline void SimpleRecord::setCoord(Coord const & coord) { set(SimpleTable::getCoordKey(), coord); }
209 
210 inline Angle SimpleRecord::getRa() const { return get(SimpleTable::getCoordKey().getRa()); }
211 inline void SimpleRecord::setRa(Angle ra) { set(SimpleTable::getCoordKey().getRa(), ra); }
212 
213 inline Angle SimpleRecord::getDec() const { return get(SimpleTable::getCoordKey().getDec()); }
214 inline void SimpleRecord::setDec(Angle dec) { set(SimpleTable::getCoordKey().getDec(), dec); }
215 
216 #endif // !SWIG
217 
218 }}} // namespace lsst::afw::table
219 
220 #endif // !AFW_TABLE_Simple_h_INCLUDED
boost::shared_ptr< IdFactory > _idFactory
Definition: Simple.h:198
Defines the fields and offsets for a table.
Definition: Schema.h:46
void setId(RecordId id)
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:204
SortedCatalogT< Record const > ConstCatalog
Definition: Simple.h:90
#define CONST_PTR(...)
Definition: base.h:47
Writer subclass for FITS binary tables.
Definition: FitsWriter.h:20
SortedCatalogT< SimpleRecord > Catalog
Definition: Simple.h:50
boost::shared_ptr< SimpleTable > clone() const
Return a polymorphic deep copy of the table.
Definition: Simple.h:158
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:19
static Schema makeMinimalSchema()
Return a minimal schema for Simple tables and records.
Definition: Simple.h:120
static boost::shared_ptr< SimpleTable > make(Schema const &schema)
Construct a new table.
Definition: Simple.h:111
boost::shared_ptr< BaseTable const > getTable() const
Return the table this record is associated with.
Definition: BaseRecord.h:51
ColumnViewT< SimpleRecord > ColumnView
Definition: Simple.h:49
boost::shared_ptr< IdFactory > getIdFactory()
Return the object that generates IDs for the table (may be null).
Definition: Simple.h:137
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:203
virtual boost::shared_ptr< BaseTable > _clone() const =0
Clone implementation with noncovariant return types.
static boost::shared_ptr< IdFactory > makeSimple()
Return a simple IdFactory that simply counts from 1.
#define PTR(...)
Definition: base.h:41
static MinimalSchema & getMinimalSchema()
SimpleRecord(boost::shared_ptr< SimpleTable > const &table)
static bool checkSchema(Schema const &other)
Return true if the given schema is a valid SimpleTable schema.
Definition: Simple.h:132
virtual boost::shared_ptr< BaseRecord > _makeRecord()=0
Default-construct an associated record (protected implementation).
SortedCatalogT< Record > Catalog
Definition: Simple.h:89
IcrsCoord getCoord() const
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:206
Table class that must contain a unique ID field and a celestial coordinate field. ...
Definition: Simple.h:84
int contains(Schema const &other, int flags=EQUAL_KEYS) const
Test whether the given schema is a subset of this.
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:143
tbl::Schema schema
Definition: CoaddPsf.cc:324
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
SimpleRecord Record
Definition: Simple.h:87
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:161
static Key< RecordId > getIdKey()
Key for the unique ID.
Definition: Simple.h:152
A polymorphic functor base class for generating record IDs for a table.
Definition: IdFactory.h:19
boost::shared_ptr< BaseRecord > copyRecord(BaseRecord const &input)
Deep-copy a record, requiring that it have the same schema as this table.
ColumnViewT< SimpleRecord > ColumnView
Definition: Simple.h:88
void setCoord(IcrsCoord const &coord)
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:207
Base class for all records.
Definition: BaseRecord.h:27
void disconnectAliases()
Sever the connection between this schema and any others with which it shares aliases.
static Key< Coord > getCoordKey()
Key for the celestial coordinates.
Definition: Simple.h:154
Angle getDec() const
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:213
SimpleTable(Schema const &schema, boost::shared_ptr< IdFactory > const &idFactory)
void setDec(Angle dec)
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:164
Record class that must contain a unique ID field and a celestial coordinate field.
Definition: Simple.h:45
boost::shared_ptr< SimpleTable const > getTable() const
Definition: Simple.h:53
SortedCatalogT< SimpleRecord const > ConstCatalog
Definition: Simple.h:51
boost::int64_t RecordId
Type used for unique IDs for records.
Definition: misc.h:21
std::map< Citizen const *, CitizenInfo > table
Definition: Citizen.h:93
A class to handle Icrs coordinates (inherits from Coord)
Definition: Coord.h:155
void setRa(Angle ra)
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:211
Base class for all tables.
Definition: BaseTable.h:44
Angle getRa() const
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:210