LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
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 
65  BaseRecord(token, std::move(data))
66  {}
67 
69  return std::static_pointer_cast<SimpleTable const>(BaseRecord::getTable());
70  }
71 
73  RecordId getId() const;
75  void setId(RecordId id);
76 
78  void setCoord(lsst::geom::SpherePoint const& coord);
79 
80  lsst::geom::Angle getRa() const;
81  void setRa(lsst::geom::Angle ra);
82 
83  lsst::geom::Angle getDec() const;
86 
87  SimpleRecord(const SimpleRecord&) = delete;
88  SimpleRecord& operator=(const SimpleRecord&) = delete;
91  ~SimpleRecord() override;
92 
93 private:
94  friend class SimpleTable;
95 };
96 
102 class SimpleTable : public BaseTable {
103 public:
108 
120  std::shared_ptr<IdFactory> const& idFactory);
121 
130  return make(schema, IdFactory::makeSimple());
131  }
132 
141  Schema r = getMinimalSchema().schema;
142  r.disconnectAliases();
143  return r;
144  }
145 
152  static bool checkSchema(Schema const& other) { return other.contains(getMinimalSchema().schema); }
153 
155  std::shared_ptr<IdFactory> getIdFactory() { return _idFactory; }
156 
158  std::shared_ptr<IdFactory const> getIdFactory() const { return _idFactory; }
159 
161  void setIdFactory(std::shared_ptr<IdFactory> f) { _idFactory = f; }
162 
164 
169  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 
193  SimpleTable& operator=(SimpleTable const&) = delete;
195  ~SimpleTable() override;
196 
197 protected:
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 
207 private:
208  // Struct that holds the minimal schema and the special keys we've added to it.
209  struct MinimalSchema {
210  Schema schema;
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 
233  set(SimpleTable::getCoordKey(), coord);
234 }
235 
238 
241 } // namespace table
242 } // namespace afw
243 } // namespace lsst
244 
245 #endif // !AFW_TABLE_Simple_h_INCLUDED
schema
table::Schema schema
Definition: Amplifier.cc:115
lsst::afw::table::SimpleTable::make
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
STL class.
lsst::afw::table::SimpleRecord::SimpleRecord
SimpleRecord(SimpleRecord &&)=delete
lsst::afw::table::SimpleTable::SimpleTable
SimpleTable(Schema const &schema, std::shared_ptr< IdFactory > const &idFactory)
Definition: Simple.cc:84
lsst::afw::table::SimpleRecord::~SimpleRecord
~SimpleRecord() override
lsst::afw::table::SimpleTable::clone
std::shared_ptr< SimpleTable > clone() const
Return a polymorphic deep copy of the table.
Definition: Simple.h:176
lsst::afw::table::BaseRecord::get
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
Definition: BaseRecord.h:151
lsst::afw::table::ColumnViewT
Definition: BaseColumnView.h:170
lsst::afw::table::SimpleTable::checkSchema
static bool checkSchema(Schema const &other)
Return true if the given schema is a valid SimpleTable schema.
Definition: Simple.h:152
lsst::afw::table::SimpleRecord::getDec
lsst::geom::Angle getDec() const
Definition: Simple.h:239
lsst::afw::table::SimpleTable::ColumnView
ColumnViewT< SimpleRecord > ColumnView
Definition: Simple.h:105
lsst::afw::table::SimpleTable::Record
SimpleRecord Record
Definition: Simple.h:104
lsst::afw::fits::Fits
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:297
lsst::afw::table::CoordKey
A FunctorKey used to get or set celestial coordinates from a pair of lsst::geom::Angle keys.
Definition: aggregates.h:210
lsst::afw::table::SimpleTable::ConstCatalog
SortedCatalogT< Record const > ConstCatalog
Definition: Simple.h:107
lsst::afw::table::SimpleRecord::Catalog
SortedCatalogT< SimpleRecord > Catalog
Definition: Simple.h:52
lsst::afw::table::SimpleTable::getIdKey
static Key< RecordId > getIdKey()
Get keys for standard fields shared by all references.
Definition: Simple.h:170
dec
double dec
Definition: Match.cc:41
lsst::afw::table::SimpleTable::make
static std::shared_ptr< SimpleTable > make(Schema const &schema)
Construct a new table.
Definition: Simple.h:129
lsst::afw::table::IdFactory::makeSimple
static std::shared_ptr< IdFactory > makeSimple()
Return a simple IdFactory that simply counts from 1.
Definition: IdFactory.cc:70
lsst::afw
Definition: imageAlgorithm.dox:1
BaseColumnView.h
lsst::afw::table::Schema
Defines the fields and offsets for a table.
Definition: Schema.h:50
lsst::afw::table::SimpleTable::operator=
SimpleTable & operator=(SimpleTable &&)=delete
lsst::afw::table::detail::RecordData
Helper struct that contains the information passed from BaseTable to BaseRecord at construction.
Definition: BaseTable.h:32
aggregates.h
lsst::afw::table::BaseTable
Base class for all tables.
Definition: BaseTable.h:61
lsst::afw::table::SimpleRecord::operator=
SimpleRecord & operator=(SimpleRecord &&)=delete
lsst::afw::table::SimpleRecord::getTable
std::shared_ptr< SimpleTable const > getTable() const
Definition: Simple.h:68
lsst::afw::table::SimpleRecord::operator=
SimpleRecord & operator=(const SimpleRecord &)=delete
BaseRecord.h
lsst::afw::table::SimpleTable::getCoordKey
static CoordKey getCoordKey()
Key for the celestial coordinates.
Definition: Simple.h:172
data
char * data
Definition: BaseRecord.cc:62
lsst::afw::table::SimpleRecord::SimpleRecord
SimpleRecord(ConstructionToken const &token, detail::RecordData &&data)
Constructor used by SimpleTable.
Definition: Simple.h:64
id
table::Key< int > id
Definition: Detector.cc:162
lsst::afw::table::SimpleRecord::ColumnView
ColumnViewT< SimpleRecord > ColumnView
Definition: Simple.h:51
lsst::afw::table::SimpleTable::copyRecord
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
lsst::afw::table::SimpleTable::operator=
SimpleTable & operator=(SimpleTable const &)=delete
other
ItemVariant const * other
Definition: Schema.cc:56
lsst::afw::table::BaseRecord
Base class for all records.
Definition: BaseRecord.h:31
lsst::afw::table::SimpleTable::getIdFactory
std::shared_ptr< IdFactory const > getIdFactory() const
Return the object that generates IDs for the table (may be null).
Definition: Simple.h:158
lsst::afw::table::SimpleTable::_makeRecord
std::shared_ptr< BaseRecord > _makeRecord() override
Default-construct an associated record (protected implementation).
Definition: Simple.cc:112
lsst::afw::table::SchemaMapper
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:21
lsst::afw::table::SimpleRecord::getCoord
lsst::geom::SpherePoint getCoord() const
Definition: Simple.h:231
IdFactory.h
lsst::afw::table::Key
A class used as a handle to a particular field in a table.
Definition: fwd.h:45
lsst::afw::table::SimpleTable::copyRecord
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
lsst::afw::table::SimpleRecord::ConstCatalog
SortedCatalogT< SimpleRecord const > ConstCatalog
Definition: Simple.h:53
std::int64_t
lsst::afw::table::SimpleRecord::setDec
void setDec(lsst::geom::Angle dec)
Definition: Simple.h:240
SortedCatalog.h
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::afw::table::SimpleTable::Catalog
SortedCatalogT< Record > Catalog
Definition: Simple.h:106
lsst::afw::table::BaseRecord::ConstructionToken
Definition: BaseRecord.h:38
lsst::afw::table::SimpleTable
Table class that must contain a unique ID field and a celestial coordinate field.
Definition: Simple.h:102
lsst::afw::table::SimpleRecord::Table
SimpleTable Table
Definition: Simple.h:50
lsst::afw::table::SimpleTable::setIdFactory
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
lsst::afw::table::SimpleTable::_clone
std::shared_ptr< BaseTable > _clone() const override
Clone implementation with noncovariant return types.
Definition: Simple.cc:108
lsst::afw::table::SimpleTable::makeRecord
std::shared_ptr< SimpleRecord > makeRecord()
Default-construct an associated record.
Definition: Simple.h:179
std
STL namespace.
lsst::afw::table::SimpleTable::makeMinimalSchema
static Schema makeMinimalSchema()
Return a minimal schema for Simple tables and records.
Definition: Simple.h:140
lsst::afw::table::io::FitsWriter
Writer object for FITS binary tables.
Definition: FitsWriter.h:25
lsst::afw::table::SimpleRecord::setId
void setId(RecordId id)
Definition: Simple.h:229
lsst::geom::Angle
A class representing an angle.
Definition: Angle.h:127
lsst::afw::table::BaseTable::copyRecord
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
mapper
SchemaMapper * mapper
Definition: SchemaMapper.cc:78
BaseTable.h
lsst::afw::table::BaseRecord::getTable
std::shared_ptr< BaseTable const > getTable() const
Return the table this record is associated with.
Definition: BaseRecord.h:83
lsst::afw::table::Schema::disconnectAliases
void disconnectAliases()
Sever the connection between this schema and any others with which it shares aliases.
Definition: Schema.cc:729
lsst::geom::SpherePoint
Point in an unspecified spherical coordinate system.
Definition: SpherePoint.h:57
lsst::afw::table::SimpleTable::getIdFactory
std::shared_ptr< IdFactory > getIdFactory()
Return the object that generates IDs for the table (may be null).
Definition: Simple.h:155
lsst::afw::table::SimpleRecord
Record class that must contain a unique ID field and a celestial coordinate field.
Definition: Simple.h:48
lsst::afw::table::BaseRecord::set
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
Definition: BaseRecord.h:164
lsst::afw::table::SimpleRecord::getRa
lsst::geom::Angle getRa() const
Definition: Simple.h:236
Catalog.h
lsst::afw::table::SimpleRecord::setCoord
void setCoord(lsst::geom::SpherePoint const &coord)
Definition: Simple.h:232
lsst::afw::table::SimpleTable::~SimpleTable
~SimpleTable() override
lsst::afw::table::SimpleRecord::setRa
void setRa(lsst::geom::Angle ra)
Definition: Simple.h:237
lsst::afw::table::SortedCatalogT
Custom catalog class for record/table subclasses that are guaranteed to have an ID,...
Definition: fwd.h:63
lsst::afw::table::SimpleRecord::getId
RecordId getId() const
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:228
lsst::afw::table::SimpleRecord::SimpleRecord
SimpleRecord(const SimpleRecord &)=delete