LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
lsst::afw::table::SimpleRecord Class Reference

Record class that must contain a unique ID field and a celestial coordinate field. More...

#include <Simple.h>

Inheritance diagram for lsst::afw::table::SimpleRecord:
lsst::afw::table::BaseRecord lsst::afw::table::SourceRecord

Public Types

typedef SimpleTable Table
 
typedef ColumnViewT< SimpleRecordColumnView
 
typedef SortedCatalogT< SimpleRecordCatalog
 
typedef SortedCatalogT< SimpleRecord const > ConstCatalog
 

Public Member Functions

 SimpleRecord (ConstructionToken const &token, detail::RecordData &&data)
 Constructor used by SimpleTable. More...
 
std::shared_ptr< SimpleTable const > getTable () const
 
 SimpleRecord (const SimpleRecord &)=delete
 
SimpleRecordoperator= (const SimpleRecord &)=delete
 
 SimpleRecord (SimpleRecord &&)=delete
 
SimpleRecordoperator= (SimpleRecord &&)=delete
 
 ~SimpleRecord () override
 
Schema getSchema () const
 Return the Schema that holds this record's fields and keys. More...
 
template<typename T >
Field< T >::Element * getElement (Key< T > const &key)
 Return a pointer to the underlying elements of a field (non-const). More...
 
template<typename T >
Field< T >::Element const * getElement (Key< T > const &key) const
 Return a pointer to the underlying elements of a field (const). More...
 
template<typename T >
Field< T >::Reference operator[] (Key< T > const &key)
 Return a reference (or reference-like type) to the field's value. More...
 
template<typename T >
Field< T >::ConstReference operator[] (Key< T > const &key) const
 Return a const reference (or const-reference-like type) to the field's value. More...
 
template<typename Ref >
Ref operator[] (ReferenceFunctorKey< Ref > const &key)
 
template<typename ConstRef >
ConstRef operator[] (ConstReferenceFunctorKey< ConstRef > const &key) const
 
template<typename T >
Field< T >::Value get (Key< T > const &key) const
 Return the value of a field for the given key. More...
 
template<typename T >
get (OutputFunctorKey< T > const &key) const
 Compute a calculated or aggregate field. More...
 
template<typename T , typename U >
void set (Key< T > const &key, U const &value)
 Set value of a field for the given key. More...
 
template<typename T , typename U >
void set (InputFunctorKey< T > const &key, U const &value)
 Set a calculated or aggregate field. More...
 
void assign (BaseRecord const &other)
 Copy all field values from other to this, requiring that they have equal schemas. More...
 
void assign (BaseRecord const &other, SchemaMapper const &mapper)
 Copy field values from other to this, using a mapper. More...
 
ndarray::Manager::Ptr getManager () const
 
RecordId getId () const
 Convenience accessors for the keys in the minimal reference schema. More...
 
void setId (RecordId id)
 Convenience accessors for the keys in the minimal reference schema. More...
 
lsst::geom::SpherePoint getCoord () const
 Convenience accessors for the keys in the minimal reference schema. More...
 
void setCoord (lsst::geom::SpherePoint const &coord)
 Convenience accessors for the keys in the minimal reference schema. More...
 
lsst::geom::Angle getRa () const
 Convenience accessors for the keys in the minimal reference schema. More...
 
void setRa (lsst::geom::Angle ra)
 Convenience accessors for the keys in the minimal reference schema. More...
 
lsst::geom::Angle getDec () const
 Convenience accessors for the keys in the minimal reference schema. More...
 
void setDec (lsst::geom::Angle dec)
 Convenience accessors for the keys in the minimal reference schema. More...
 

Protected Member Functions

virtual void _assign (BaseRecord const &other)
 Called by assign() after transferring fields to allow subclass data members to be copied. More...
 
virtual void _stream (std::ostream &os) const
 Called by operator<<. More...
 

Friends

class SimpleTable
 

Detailed Description

Record class that must contain a unique ID field and a celestial coordinate field.

SimpleTable / SimpleRecord are intended to be the base class for records representing astronomical objects. In additional to the minimal schema and the convenience accessors it allows, a SimpleTable may hold an IdFactory object that is used to assign unique IDs to new records.

Definition at line 48 of file Simple.h.

Member Typedef Documentation

◆ Catalog

Definition at line 52 of file Simple.h.

◆ ColumnView

Definition at line 51 of file Simple.h.

◆ ConstCatalog

Definition at line 53 of file Simple.h.

◆ Table

Definition at line 50 of file Simple.h.

Constructor & Destructor Documentation

◆ SimpleRecord() [1/3]

lsst::afw::table::SimpleRecord::SimpleRecord ( ConstructionToken const &  token,
detail::RecordData &&  data 
)
inline

Constructor used by SimpleTable.

While formally public, this constructor is conceptually and effectively protected, due to the (protected) ConstructionToken argument.

This is to allow make_shared to be used, as that cannot be used on a truly protected or private constructor.

Definition at line 64 of file Simple.h.

64  :
65  BaseRecord(token, std::move(data))
66  {}
char * data
Definition: BaseRecord.cc:62
T move(T... args)
BaseRecord(ConstructionToken const &, detail::RecordData &&data)
Construct a record with uninitialized data.
Definition: BaseRecord.cc:144

◆ SimpleRecord() [2/3]

lsst::afw::table::SimpleRecord::SimpleRecord ( const SimpleRecord )
delete

◆ SimpleRecord() [3/3]

lsst::afw::table::SimpleRecord::SimpleRecord ( SimpleRecord &&  )
delete

◆ ~SimpleRecord()

lsst::afw::table::SimpleRecord::~SimpleRecord ( )
overridedefault

Member Function Documentation

◆ _assign()

virtual void lsst::afw::table::BaseRecord::_assign ( BaseRecord const &  other)
inlineprotectedvirtualinherited

Called by assign() after transferring fields to allow subclass data members to be copied.

Reimplemented in lsst::afw::table::SourceRecord, and lsst::afw::table::ExposureRecord.

Definition at line 209 of file BaseRecord.h.

209 {}

◆ _stream()

void lsst::afw::table::BaseRecord::_stream ( std::ostream os) const
protectedvirtualinherited

Called by operator<<.

Overrides should call the base class implementation and append additional fields on new lines, with the syntax "%(name)s: %(value)s".

Definition at line 153 of file BaseRecord.cc.

153  {
154  getSchema().forEach([&os, this](auto const& item) {
155  os << item.field.getName() << ": " << this->get(item.key) << std::endl;
156  });
157 }
T endl(T... args)
void forEach(F &&func) const
Apply a functor to each SchemaItem in the Schema.
Definition: Schema.h:212
Schema getSchema() const
Return the Schema that holds this record&#39;s fields and keys.
Definition: BaseRecord.h:80

◆ assign() [1/2]

void lsst::afw::table::BaseRecord::assign ( BaseRecord const &  other)
inherited

Copy all field values from other to this, requiring that they have equal schemas.

Definition at line 123 of file BaseRecord.cc.

123  {
124  if (this->getSchema() != other.getSchema()) {
125  throw LSST_EXCEPT(lsst::pex::exceptions::LogicError, "Unequal schemas in record assignment.");
126  }
127  this->getSchema().forEach(CopyValue(&other, this));
128  this->_assign(other); // let derived classes assign their own stuff
129 }
virtual void _assign(BaseRecord const &other)
Called by assign() after transferring fields to allow subclass data members to be copied...
Definition: BaseRecord.h:209
ItemVariant const * other
Definition: Schema.cc:56
void forEach(F &&func) const
Apply a functor to each SchemaItem in the Schema.
Definition: Schema.h:212
Schema getSchema() const
Return the Schema that holds this record&#39;s fields and keys.
Definition: BaseRecord.h:80
Reports errors in the logical structure of the program.
Definition: Runtime.h:46
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ assign() [2/2]

void lsst::afw::table::BaseRecord::assign ( BaseRecord const &  other,
SchemaMapper const &  mapper 
)
inherited

Copy field values from other to this, using a mapper.

Definition at line 131 of file BaseRecord.cc.

131  {
132  if (!other.getSchema().contains(mapper.getInputSchema())) {
134  "Unequal schemas between input record and mapper.");
135  }
136  if (!this->getSchema().contains(mapper.getOutputSchema())) {
138  "Unequal schemas between output record and mapper.");
139  }
140  mapper.forEach(CopyValue(&other, this)); // use the functor we defined above
141  this->_assign(other); // let derived classes assign their own stuff
142 }
virtual void _assign(BaseRecord const &other)
Called by assign() after transferring fields to allow subclass data members to be copied...
Definition: BaseRecord.h:209
ItemVariant const * other
Definition: Schema.cc:56
SchemaMapper * mapper
Definition: SchemaMapper.cc:78
Schema getSchema() const
Return the Schema that holds this record&#39;s fields and keys.
Definition: BaseRecord.h:80
Reports errors in the logical structure of the program.
Definition: Runtime.h:46
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ get() [1/2]

template<typename T >
Field<T>::Value lsst::afw::table::BaseRecord::get ( Key< T > const &  key) const
inlineinherited

Return the value of a field for the given key.

No checking is done to ensure the Key belongs to the correct schema.

Definition at line 151 of file BaseRecord.h.

151  {
152  return key.getValue(getElement(key), _manager);
153  }
Key< U > key
Definition: Schema.cc:281
Field< T >::Element * getElement(Key< T > const &key)
Return a pointer to the underlying elements of a field (non-const).
Definition: BaseRecord.h:93

◆ get() [2/2]

template<typename T >
T lsst::afw::table::BaseRecord::get ( OutputFunctorKey< T > const &  key) const
inlineinherited

Compute a calculated or aggregate field.

Definition at line 172 of file BaseRecord.h.

172  {
173  return key.get(*this);
174  }
Key< U > key
Definition: Schema.cc:281

◆ getCoord()

lsst::geom::SpherePoint lsst::afw::table::SimpleRecord::getCoord ( ) const
inline

Convenience accessors for the keys in the minimal reference schema.

Definition at line 231 of file Simple.h.

231 { return get(SimpleTable::getCoordKey()); }
static CoordKey getCoordKey()
Key for the celestial coordinates.
Definition: Simple.h:172

◆ getDec()

lsst::geom::Angle lsst::afw::table::SimpleRecord::getDec ( ) const
inline

Convenience accessors for the keys in the minimal reference schema.

Definition at line 239 of file Simple.h.

239 { return get(SimpleTable::getCoordKey().getDec()); }
Key< lsst::geom::Angle > getDec() const noexcept
Return a constituent Key.
Definition: aggregates.h:268
static CoordKey getCoordKey()
Key for the celestial coordinates.
Definition: Simple.h:172

◆ getElement() [1/2]

template<typename T >
Field<T>::Element* lsst::afw::table::BaseRecord::getElement ( Key< T > const &  key)
inlineinherited

Return a pointer to the underlying elements of a field (non-const).

This low-level access is intended mostly for use with serialization; users should generally prefer the safer get(), set() and operator[] member functions.

Definition at line 93 of file BaseRecord.h.

93  {
94  if (!key.isValid()) {
95  throw LSST_EXCEPT(
96  pex::exceptions::LogicError,
97  "Key is not valid (if this is a SourceRecord, make sure slot aliases have been set up).");
98  }
99  return reinterpret_cast<typename Field<T>::Element*>(reinterpret_cast<char*>(_data) +
100  key.getOffset());
101  }
Key< U > key
Definition: Schema.cc:281
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
FieldBase< T >::Element Element
Type used to store field data in the table (a field may have multiple elements).
Definition: Field.h:26

◆ getElement() [2/2]

template<typename T >
Field<T>::Element const* lsst::afw::table::BaseRecord::getElement ( Key< T > const &  key) const
inlineinherited

Return a pointer to the underlying elements of a field (const).

This low-level access is intended mostly for use with serialization; users should generally prefer the safer get(), set() and operator[] member functions.

Definition at line 111 of file BaseRecord.h.

111  {
112  if (!key.isValid()) {
113  throw LSST_EXCEPT(
114  pex::exceptions::LogicError,
115  "Key is not valid (if this is a SourceRecord, make sure slot aliases have been set up).");
116  }
117  return reinterpret_cast<typename Field<T>::Element const*>(reinterpret_cast<char const*>(_data) +
118  key.getOffset());
119  }
Key< U > key
Definition: Schema.cc:281
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
FieldBase< T >::Element Element
Type used to store field data in the table (a field may have multiple elements).
Definition: Field.h:26

◆ getId()

RecordId lsst::afw::table::SimpleRecord::getId ( ) const
inline

Convenience accessors for the keys in the minimal reference schema.

Definition at line 228 of file Simple.h.

228 { return get(SimpleTable::getIdKey()); }
static Key< RecordId > getIdKey()
Get keys for standard fields shared by all references.
Definition: Simple.h:170

◆ getManager()

ndarray::Manager::Ptr lsst::afw::table::BaseRecord::getManager ( ) const
inlineinherited

Definition at line 200 of file BaseRecord.h.

200 { return _manager; }

◆ getRa()

lsst::geom::Angle lsst::afw::table::SimpleRecord::getRa ( ) const
inline

Convenience accessors for the keys in the minimal reference schema.

Definition at line 236 of file Simple.h.

236 { return get(SimpleTable::getCoordKey().getRa()); }
Key< lsst::geom::Angle > getRa() const noexcept
Return a constituent Key.
Definition: aggregates.h:267
static CoordKey getCoordKey()
Key for the celestial coordinates.
Definition: Simple.h:172

◆ getSchema()

Schema lsst::afw::table::BaseRecord::getSchema ( ) const
inlineinherited

Return the Schema that holds this record's fields and keys.

Definition at line 80 of file BaseRecord.h.

80 { return _table->getSchema(); }

◆ getTable()

std::shared_ptr<SimpleTable const> lsst::afw::table::SimpleRecord::getTable ( ) const
inline

Definition at line 68 of file Simple.h.

68  {
70  }
T static_pointer_cast(T... args)
std::shared_ptr< BaseTable const > getTable() const
Return the table this record is associated with.
Definition: BaseRecord.h:83
friend class SimpleTable
Definition: Simple.h:94

◆ operator=() [1/2]

SimpleRecord& lsst::afw::table::SimpleRecord::operator= ( const SimpleRecord )
delete

◆ operator=() [2/2]

SimpleRecord& lsst::afw::table::SimpleRecord::operator= ( SimpleRecord &&  )
delete

◆ operator[]() [1/4]

template<typename T >
Field<T>::Reference lsst::afw::table::BaseRecord::operator[] ( Key< T > const &  key)
inlineinherited

Return a reference (or reference-like type) to the field's value.

Some field types (Point, Moments, Flag, Covariance, and SpherePoint) do not support reference access.

No checking is done to ensure the Key belongs to the correct schema.

Definition at line 129 of file BaseRecord.h.

129  {
130  return key.getReference(getElement(key), _manager);
131  }
Key< U > key
Definition: Schema.cc:281
Field< T >::Element * getElement(Key< T > const &key)
Return a pointer to the underlying elements of a field (non-const).
Definition: BaseRecord.h:93

◆ operator[]() [2/4]

template<typename T >
Field<T>::ConstReference lsst::afw::table::BaseRecord::operator[] ( Key< T > const &  key) const
inlineinherited

Return a const reference (or const-reference-like type) to the field's value.

Some field types (Point, Moments, Flag, Covariance, and SpherePoint) do not support reference access.

No checking is done to ensure the Key belongs to the correct schema.

Definition at line 141 of file BaseRecord.h.

141  {
142  return key.getConstReference(getElement(key), _manager);
143  }
Key< U > key
Definition: Schema.cc:281
Field< T >::Element * getElement(Key< T > const &key)
Return a pointer to the underlying elements of a field (non-const).
Definition: BaseRecord.h:93

◆ operator[]() [3/4]

template<typename Ref >
Ref lsst::afw::table::BaseRecord::operator[] ( ReferenceFunctorKey< Ref > const &  key)
inlineinherited

Definition at line 185 of file BaseRecord.h.

185  {
186  return key.getReference(*this);
187  }
Key< U > key
Definition: Schema.cc:281

◆ operator[]() [4/4]

template<typename ConstRef >
ConstRef lsst::afw::table::BaseRecord::operator[] ( ConstReferenceFunctorKey< ConstRef > const &  key) const
inlineinherited

Definition at line 190 of file BaseRecord.h.

190  {
191  return key.getConstReference(*this);
192  }
Key< U > key
Definition: Schema.cc:281

◆ set() [1/2]

template<typename T , typename U >
void lsst::afw::table::BaseRecord::set ( Key< T > const &  key,
U const &  value 
)
inlineinherited

Set value of a field for the given key.

This method has an additional template parameter because some fields accept and convert different types to the stored field type.

No checking is done to ensure the Key belongs to the correct schema.

Definition at line 164 of file BaseRecord.h.

164  {
165  key.setValue(getElement(key), _manager, value);
166  }
Key< U > key
Definition: Schema.cc:281
Field< T >::Element * getElement(Key< T > const &key)
Return a pointer to the underlying elements of a field (non-const).
Definition: BaseRecord.h:93

◆ set() [2/2]

template<typename T , typename U >
void lsst::afw::table::BaseRecord::set ( InputFunctorKey< T > const &  key,
U const &  value 
)
inlineinherited

Set a calculated or aggregate field.

Definition at line 180 of file BaseRecord.h.

180  {
181  return key.set(*this, value);
182  }
Key< U > key
Definition: Schema.cc:281

◆ setCoord()

void lsst::afw::table::SimpleRecord::setCoord ( lsst::geom::SpherePoint const &  coord)
inline

Convenience accessors for the keys in the minimal reference schema.

Definition at line 232 of file Simple.h.

232  {
233  set(SimpleTable::getCoordKey(), coord);
234 }
static CoordKey getCoordKey()
Key for the celestial coordinates.
Definition: Simple.h:172

◆ setDec()

void lsst::afw::table::SimpleRecord::setDec ( lsst::geom::Angle  dec)
inline

Convenience accessors for the keys in the minimal reference schema.

Definition at line 240 of file Simple.h.

240 { set(SimpleTable::getCoordKey().getDec(), dec); }
double dec
Definition: Match.cc:41
Key< lsst::geom::Angle > getDec() const noexcept
Return a constituent Key.
Definition: aggregates.h:268
static CoordKey getCoordKey()
Key for the celestial coordinates.
Definition: Simple.h:172

◆ setId()

void lsst::afw::table::SimpleRecord::setId ( RecordId  id)
inline

Convenience accessors for the keys in the minimal reference schema.

Definition at line 229 of file Simple.h.

229 { set(SimpleTable::getIdKey(), id); }
static Key< RecordId > getIdKey()
Get keys for standard fields shared by all references.
Definition: Simple.h:170
table::Key< int > id
Definition: Detector.cc:162

◆ setRa()

void lsst::afw::table::SimpleRecord::setRa ( lsst::geom::Angle  ra)
inline

Convenience accessors for the keys in the minimal reference schema.

Definition at line 237 of file Simple.h.

237 { set(SimpleTable::getCoordKey().getRa(), ra); }
Key< lsst::geom::Angle > getRa() const noexcept
Return a constituent Key.
Definition: aggregates.h:267
static CoordKey getCoordKey()
Key for the celestial coordinates.
Definition: Simple.h:172

Friends And Related Function Documentation

◆ SimpleTable

friend class SimpleTable
friend

Definition at line 94 of file Simple.h.


The documentation for this class was generated from the following files: