LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
lsst::afw::table::BaseRecord Class Reference

Base class for all records. More...

#include <BaseRecord.h>

Inheritance diagram for lsst::afw::table::BaseRecord:
lsst::daf::base::Citizen lsst::afw::detection::PeakRecord lsst::afw::table::AmpInfoRecord lsst::afw::table::ExposureRecord lsst::afw::table::SimpleRecord lsst::afw::table::SourceRecord

Public Types

typedef BaseTable Table
 The associated table class. More...
 
typedef BaseColumnView ColumnView
 The associated ColumnView class. More...
 
typedef CatalogT< BaseRecordCatalog
 Template of CatalogT used to hold records of this type. More...
 
typedef CatalogT< BaseRecord
const > 
ConstCatalog
 Template of CatalogT used to hold const records of this type. More...
 
- Public Types inherited from lsst::daf::base::Citizen
enum  { magicSentinel = 0xdeadbeef }
 
typedef unsigned long memId
 Type of the block's ID. More...
 
typedef memId(* memNewCallback )(const memId cid)
 A function used to register a callback. More...
 
typedef memId(* memCallback )(const Citizen *ptr)
 

Public Member Functions

Schema getSchema () const
 Return the Schema that holds this record's fields and keys. More...
 
boost::shared_ptr< BaseTable
const > 
getTable () const
 Return the table this record is associated with. 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 T >
Field< T >::Value get (Key< T > const &key) const
 Return the value of a field for the given key. 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 >
get (OutputFunctorKey< T > const &key) const
 Compute a calculated or aggregate field. More...
 
template<typename T , typename U >
void set (InputFunctorKey< T > const &key, U const &value)
 Set a calculated or aggregate field. More...
 
template<typename Ref >
Ref operator[] (ReferenceFunctorKey< Ref > const &key)
 
template<typename ConstRef >
ConstRef operator[] (ConstReferenceFunctorKey< ConstRef > const &key) const
 
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
 
virtual ~BaseRecord ()
 
- Public Member Functions inherited from lsst::daf::base::Citizen
 Citizen (const std::type_info &)
 
 Citizen (Citizen const &)
 
 ~Citizen ()
 
Citizenoperator= (Citizen const &)
 
std::string repr () const
 Return a string representation of a Citizen. More...
 
void markPersistent (void)
 Mark a Citizen as persistent and not destroyed until process end. More...
 
memId getId () const
 Return the Citizen's ID. 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...
 
 BaseRecord (boost::shared_ptr< BaseTable > const &table)
 Construct a record with uninitialized data. More...
 

Private Attributes

void * _data
 
boost::shared_ptr< BaseTable_table
 
ndarray::Manager::Ptr _manager
 

Friends

class BaseTable
 
class BaseColumnView
 

Additional Inherited Members

- Static Public Member Functions inherited from lsst::daf::base::Citizen
static bool hasBeenCorrupted ()
 Check all allocated blocks for corruption. More...
 
static memId getNextMemId ()
 Return the memId of the next object to be allocated. More...
 
static int init ()
 Called once when the memory system is being initialised. More...
 
static int census (int, memId startingMemId=0)
 How many active Citizens are there? More...
 
static void census (std::ostream &stream, memId startingMemId=0)
 Print a list of all active Citizens to stream, sorted by ID. More...
 
static const std::vector
< const Citizen * > * 
census ()
 Return a (newly allocated) std::vector of active Citizens sorted by ID. More...
 
static memId setNewCallbackId (memId id)
 Call the NewCallback when block is allocated. More...
 
static memId setDeleteCallbackId (memId id)
 Call the current DeleteCallback when block is deleted. More...
 
static memNewCallback setNewCallback (memNewCallback func)
 Set the NewCallback function. More...
 
static memCallback setDeleteCallback (memCallback func)
 Set the DeleteCallback function. More...
 
static memCallback setCorruptionCallback (memCallback func)
 Set the CorruptionCallback function. More...
 

Detailed Description

Base class for all records.

BaseRecord is a polymorphic base class that provides the core record interface: access to fields and links back to the table it is associated with. Field access is provided by the templated get, set, and operator[] member functions. As templates they are nonvirtual and cannot be overridden by subclasses. The implementations for these accessors is in the FieldBase template specializations.

Each subclass of BaseRecord should be paired with a subclass of BaseTable. All record creation goes through a table, as the table allocates the memory used to store a record's fields and holds the Schema instance that defines those fields.

Records are noncopyable, and are hence usually passed by shared_ptr or [const-]reference.

Definition at line 27 of file BaseRecord.h.

Member Typedef Documentation

Template of CatalogT used to hold records of this type.

Definition at line 42 of file BaseRecord.h.

The associated ColumnView class.

Definition at line 39 of file BaseRecord.h.

Template of CatalogT used to hold const records of this type.

Definition at line 45 of file BaseRecord.h.

The associated table class.

Definition at line 36 of file BaseRecord.h.

Constructor & Destructor Documentation

virtual lsst::afw::table::BaseRecord::~BaseRecord ( )
inlinevirtual

Definition at line 178 of file BaseRecord.h.

178 { _table->_destroy(*this); }
boost::shared_ptr< BaseTable > _table
Definition: BaseRecord.h:197
lsst::afw::table::BaseRecord::BaseRecord ( boost::shared_ptr< BaseTable > const &  table)
inlineprotected

Construct a record with uninitialized data.

Definition at line 186 of file BaseRecord.h.

186  : daf::base::Citizen(typeid(this)), _table(table) {
187  table->_initialize(*this);
188  }
boost::shared_ptr< BaseTable > _table
Definition: BaseRecord.h:197
std::map< Citizen const *, CitizenInfo > table
Definition: Citizen.h:93

Member Function Documentation

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

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 183 of file BaseRecord.h.

183 {}
void lsst::afw::table::BaseRecord::assign ( BaseRecord const &  other)

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

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

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

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

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 123 of file BaseRecord.h.

123  {
124  return key.getValue(getElement(key), _manager);
125  }
Field< T >::Element * getElement(Key< T > const &key)
Return a pointer to the underlying elements of a field (non-const).
Definition: BaseRecord.h:61
ndarray::Manager::Ptr _manager
Definition: BaseRecord.h:198
template<typename T >
T lsst::afw::table::BaseRecord::get ( OutputFunctorKey< T > const &  key) const
inline

Compute a calculated or aggregate field.

Definition at line 146 of file BaseRecord.h.

146  {
147  return key.get(*this);
148  }
template<typename T >
Field<T>::Element* lsst::afw::table::BaseRecord::getElement ( Key< T > const &  key)
inline

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 61 of file BaseRecord.h.

61  {
62  if (!key.isValid()) {
63  throw LSST_EXCEPT(
64  pex::exceptions::LogicError,
65  "Key is not valid (if this is a SourceRecord, make sure slot aliases have been setup)."
66  );
67  }
68  return reinterpret_cast<typename Field<T>::Element*>(
69  reinterpret_cast<char*>(_data) + key.getOffset()
70  );
71  }
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename T >
Field<T>::Element const* lsst::afw::table::BaseRecord::getElement ( Key< T > const &  key) const
inline

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 81 of file BaseRecord.h.

81  {
82  if (!key.isValid()) {
83  throw LSST_EXCEPT(
84  pex::exceptions::LogicError,
85  "Key is not valid (if this is a SourceRecord, make sure slot aliases have been setup)."
86  );
87  }
88  return reinterpret_cast<typename Field<T>::Element const *>(
89  reinterpret_cast<char const *>(_data) + key.getOffset()
90  );
91  }
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
ndarray::Manager::Ptr lsst::afw::table::BaseRecord::getManager ( ) const
inline

Definition at line 176 of file BaseRecord.h.

176 { return _manager; }
ndarray::Manager::Ptr _manager
Definition: BaseRecord.h:198
Schema lsst::afw::table::BaseRecord::getSchema ( ) const
inline

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

Definition at line 48 of file BaseRecord.h.

48 { return _table->getSchema(); }
boost::shared_ptr< BaseTable > _table
Definition: BaseRecord.h:197
boost::shared_ptr< BaseTable const> lsst::afw::table::BaseRecord::getTable ( ) const
inline

Return the table this record is associated with.

Definition at line 51 of file BaseRecord.h.

51 { return _table; }
boost::shared_ptr< BaseTable > _table
Definition: BaseRecord.h:197
template<typename T >
Field<T>::Reference lsst::afw::table::BaseRecord::operator[] ( Key< T > const &  key)
inline

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

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

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

Definition at line 101 of file BaseRecord.h.

101  {
102  return key.getReference(getElement(key), _manager);
103  }
Field< T >::Element * getElement(Key< T > const &key)
Return a pointer to the underlying elements of a field (non-const).
Definition: BaseRecord.h:61
ndarray::Manager::Ptr _manager
Definition: BaseRecord.h:198
template<typename T >
Field<T>::ConstReference lsst::afw::table::BaseRecord::operator[] ( Key< T > const &  key) const
inline

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

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

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

Definition at line 113 of file BaseRecord.h.

113  {
114  return key.getConstReference(getElement(key), _manager);
115  }
Field< T >::Element * getElement(Key< T > const &key)
Return a pointer to the underlying elements of a field (non-const).
Definition: BaseRecord.h:61
ndarray::Manager::Ptr _manager
Definition: BaseRecord.h:198
template<typename Ref >
Ref lsst::afw::table::BaseRecord::operator[] ( ReferenceFunctorKey< Ref > const &  key)
inline

Definition at line 159 of file BaseRecord.h.

159  {
160  return key.getReference(*this);
161  }
template<typename ConstRef >
ConstRef lsst::afw::table::BaseRecord::operator[] ( ConstReferenceFunctorKey< ConstRef > const &  key) const
inline

Definition at line 164 of file BaseRecord.h.

164  {
165  return key.getConstReference(*this);
166  }
template<typename T , typename U >
void lsst::afw::table::BaseRecord::set ( Key< T > const &  key,
U const &  value 
)
inline

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 136 of file BaseRecord.h.

136  {
137  key.setValue(getElement(key), _manager, value);
138  }
Field< T >::Element * getElement(Key< T > const &key)
Return a pointer to the underlying elements of a field (non-const).
Definition: BaseRecord.h:61
ndarray::Manager::Ptr _manager
Definition: BaseRecord.h:198
template<typename T , typename U >
void lsst::afw::table::BaseRecord::set ( InputFunctorKey< T > const &  key,
U const &  value 
)
inline

Set a calculated or aggregate field.

Definition at line 154 of file BaseRecord.h.

154  {
155  return key.set(*this, value);
156  }

Friends And Related Function Documentation

friend class BaseColumnView
friend

Definition at line 193 of file BaseRecord.h.

friend class BaseTable
friend

Definition at line 192 of file BaseRecord.h.

Member Data Documentation

void* lsst::afw::table::BaseRecord::_data
private

Definition at line 196 of file BaseRecord.h.

ndarray::Manager::Ptr lsst::afw::table::BaseRecord::_manager
private

Definition at line 198 of file BaseRecord.h.

boost::shared_ptr< BaseTable > lsst::afw::table::BaseRecord::_table
private

Definition at line 197 of file BaseRecord.h.


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