LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Peak.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2014 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_DETECTION_Peak_h_INCLUDED
24 #define AFW_DETECTION_Peak_h_INCLUDED
25 
29 #include "lsst/afw/table/Catalog.h"
31 
32 namespace lsst { namespace afw { namespace detection {
33 
34 class PeakRecord;
35 class PeakTable;
36 
41 public:
42 
43  typedef PeakTable Table;
47 
49  return boost::static_pointer_cast<PeakTable const>(afw::table::BaseRecord::getTable());
50  }
51 
55  void setId(afw::table::RecordId id);
56 
57  int getIx() const;
58  int getIy() const;
59  void setIx(int ix);
60  void setIy(int iy);
62  afw::geom::Point2I getCentroid(bool) const { return getI(); }
63 
64  float getFx() const;
65  float getFy() const;
66  void setFx(float fx);
67  void setFy(float fy);
69  afw::geom::Point2D getCentroid() const { return getF(); }
70 
71  float getPeakValue() const;
72  void setPeakValue(float peakValue);
74 
75 protected:
76 
77  PeakRecord(PTR(PeakTable) const & table);
78 
79 };
80 
85 public:
86 
87  typedef PeakRecord Record;
91 
107  static PTR(PeakTable) make(afw::table::Schema const & schema, bool forceNew=false);
108 
116  static afw::table::Schema makeMinimalSchema() { return getMinimalSchema().schema; }
117 
124  static bool checkSchema(afw::table::Schema const & other) {
125  return other.contains(getMinimalSchema().schema);
126  }
127 
130 
133 
136 
138 
150 
152  PTR(PeakTable) clone() const { return boost::static_pointer_cast<PeakTable>(_clone()); }
153 
155  PTR(PeakRecord) makeRecord() { return boost::static_pointer_cast<PeakRecord>(_makeRecord()); }
156 
158  PTR(PeakRecord) copyRecord(afw::table::BaseRecord const & other) {
159  return boost::static_pointer_cast<PeakRecord>(afw::table::BaseTable::copyRecord(other));
160  }
161 
164  afw::table::BaseRecord const & other,
165  afw::table::SchemaMapper const & mapper
166  ) {
167  return boost::static_pointer_cast<PeakRecord>(afw::table::BaseTable::copyRecord(other, mapper));
168  }
169 
170 protected:
171 
172  PeakTable(afw::table::Schema const & schema, PTR(afw::table::IdFactory) const & idFactory);
173 
174  PeakTable(PeakTable const & other);
175 
176 private:
177 
178  // Struct that holds the minimal schema and the special keys we've added to it.
179  struct MinimalSchema {
187 
188  MinimalSchema();
189  };
190 
191  // Return the singleton minimal schema.
192  static MinimalSchema & getMinimalSchema();
193 
195 
196  // Return a writer object that knows how to save in FITS format. See also FitsWriter.
197  virtual PTR(afw::table::io::FitsWriter) makeFitsWriter(fits::Fits * fitsfile, int flags) const;
198 
199  PTR(afw::table::IdFactory) _idFactory; // generates IDs for new records
200 };
201 
202 #ifndef SWIG
203 
204 std::ostream & operator<<(std::ostream & os, PeakRecord const & record);
205 
208 
209 inline int PeakRecord::getIx() const { return get(PeakTable::getIxKey()); }
210 inline int PeakRecord::getIy() const { return get(PeakTable::getIyKey()); }
211 inline void PeakRecord::setIx(int ix) { set(PeakTable::getIxKey(), ix); }
212 inline void PeakRecord::setIy(int iy) { set(PeakTable::getIyKey(), iy); }
213 
214 inline float PeakRecord::getFx() const { return get(PeakTable::getFxKey()); }
215 inline float PeakRecord::getFy() const { return get(PeakTable::getFyKey()); }
216 inline void PeakRecord::setFx(float fx) { set(PeakTable::getFxKey(), fx); }
217 inline void PeakRecord::setFy(float fy) { set(PeakTable::getFyKey(), fy); }
218 
219 inline float PeakRecord::getPeakValue() const { return get(PeakTable::getPeakValueKey()); }
220 inline void PeakRecord::setPeakValue(float peakValue) { set(PeakTable::getPeakValueKey(), peakValue); }
221 
222 #endif // !SWIG
223 
227 
228 }}} // namespace lsst::afw::detection
229 
230 #endif // !AFW_DETECTION_Peak_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:46
afw::table::ColumnViewT< PeakRecord > ColumnView
Definition: Peak.h:88
Writer object for FITS binary tables.
Definition: FitsWriter.h:22
#define PTR(...)
Definition: base.h:41
std::ostream & operator<<(std::ostream &os, PeakRecord const &record)
Definition: Peak.cc:147
boost::shared_ptr< PeakRecord > makeRecord()
Definition: Peak.h:155
void setFy(float fy)
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:217
afw::table::Key< afw::table::RecordId > id
Definition: Peak.h:181
float getFx() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:214
void setFx(float fx)
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:216
void setPeakValue(float peakValue)
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:220
afw::geom::Point2I getI() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:61
boost::shared_ptr< BaseTable const > getTable() const
Return the table this record is associated with.
Definition: BaseRecord.h:51
Table class for Peaks in Footprints.
Definition: Peak.h:84
#define CONST_PTR(...)
Definition: base.h:47
void setIy(int iy)
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:212
boost::shared_ptr< PeakTable const > getTable() const
Definition: Peak.h:48
afw::table::CatalogT< PeakRecord > PeakCatalog
Definition: Peak.h:225
static afw::table::Schema makeMinimalSchema()
Return a minimal schema for Peak tables and records.
Definition: Peak.h:116
virtual boost::shared_ptr< BaseTable > _clone() const =0
Clone implementation with noncovariant return types.
Point< int, 2 > Point2I
Definition: PSF.h:39
static bool checkSchema(afw::table::Schema const &other)
Return true if the given schema is a valid PeakTable schema.
Definition: Peak.h:124
virtual boost::shared_ptr< BaseRecord > _makeRecord()=0
Default-construct an associated record (protected implementation).
int getIy() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:210
static afw::table::Key< int > getIxKey()
Definition: Peak.h:144
static afw::table::Key< int > getIyKey()
Definition: Peak.h:145
afw::table::CatalogT< PeakRecord const > ConstCatalog
Definition: Peak.h:46
std::map< Citizen const *, CitizenInfo > table
Definition: Citizen.h:93
afw::table::CatalogT< PeakRecord const > ConstPeakCatalog
Definition: Peak.h:226
static boost::shared_ptr< PeakTable > make(afw::table::Schema const &schema, bool forceNew=false)
Obtain a table that can be used to create records with given schema.
Definition: Peak.cc:154
boost::shared_ptr< afw::table::IdFactory > getIdFactory()
Return the object that generates IDs for the table (may be null).
Definition: Peak.h:129
afw::table::Key< float > fx
Definition: Peak.h:182
int contains(Schema const &other, int flags=EQUAL_KEYS) const
Test whether the given schema is a subset of this.
static afw::table::Key< float > getFxKey()
Definition: Peak.h:146
static afw::table::Key< float > getFyKey()
Definition: Peak.h:147
afw::table::CatalogT< Record const > ConstCatalog
Definition: Peak.h:90
PeakRecord(boost::shared_ptr< PeakTable > const &table)
Definition: Peak.cc:145
static MinimalSchema & getMinimalSchema()
Definition: Peak.cc:212
afw::table::RecordId getId() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:206
float getPeakValue() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:219
afw::geom::Point2D getCentroid() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:69
void setIx(int ix)
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:211
friend class BaseRecord
Definition: BaseTable.h:201
void setIdFactory(boost::shared_ptr< afw::table::IdFactory > f)
Switch to a new IdFactory – object that generates IDs for the table (may be null).
Definition: Peak.h:135
afw::table::CatalogT< Record > Catalog
Definition: Peak.h:89
tbl::Schema schema
afw::table::ColumnViewT< PeakRecord > PeakColumnView
Definition: Peak.h:224
A polymorphic functor base class for generating record IDs for a table.
Definition: IdFactory.h:19
PeakTable(afw::table::Schema const &schema, boost::shared_ptr< afw::table::IdFactory > const &idFactory)
Definition: Peak.cc:195
boost::shared_ptr< BaseRecord > copyRecord(BaseRecord const &input)
Deep-copy a record, requiring that it have the same schema as this table.
afw::table::Key< float > fy
Definition: Peak.h:183
Base class for all records.
Definition: BaseRecord.h:27
afw::table::ColumnViewT< PeakRecord > ColumnView
Definition: Peak.h:44
afw::table::Key< float > peakValue
Definition: Peak.h:186
afw::geom::Point2I getCentroid(bool) const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:62
static afw::table::Key< float > getPeakValueKey()
Definition: Peak.h:148
float getFy() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:215
void setId(afw::table::RecordId id)
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:207
Point< double, 2 > Point2D
Definition: Point.h:286
virtual boost::shared_ptr< afw::table::io::FitsWriter > makeFitsWriter(fits::Fits *fitsfile, int flags) const
Definition: Peak.cc:218
boost::shared_ptr< PeakRecord > copyRecord(afw::table::BaseRecord const &other)
Definition: Peak.h:158
boost::shared_ptr< PeakTable > clone() const
Definition: Peak.h:152
afw::table::CatalogT< PeakRecord > Catalog
Definition: Peak.h:45
Record class that represents a peak in a Footprint.
Definition: Peak.h:40
boost::int64_t RecordId
Type used for unique IDs for records.
Definition: misc.h:21
static afw::table::Key< afw::table::RecordId > getIdKey()
Definition: Peak.h:143
afw::geom::Point2D getF() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:68
Base class for all tables.
Definition: BaseTable.h:44
int getIx() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:209
boost::shared_ptr< afw::table::IdFactory > _idFactory
Definition: Peak.h:199