lsst.afw  13.0-91-g2a3e2ee
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Friends | List of all members
lsst::afw::table::Key< T > Class Template Reference

A class used as a handle to a particular field in a table. More...

#include <fwd.h>

Inheritance diagram for lsst::afw::table::Key< T >:
lsst::afw::table::KeyBase< T > lsst::afw::table::FieldBase< T >

Public Member Functions

int getOffset () const
 Return the offset (in bytes) of this field within a record. More...
 
bool isValid () const
 Return true if the key was initialized to valid offset. More...
 
 Key ()
 Default construct a field. More...
 
template<typename OtherT >
bool operator== (Key< OtherT > const &other) const
 Equality comparison. More...
 
template<typename OtherT >
bool operator!= (Key< OtherT > const &other) const
 Equality comparison. More...
 
bool operator== (Key const &other) const
 Equality comparison. More...
 
bool operator!= (Key const &other) const
 Equality comparison. More...
 
- Public Member Functions inherited from lsst::afw::table::FieldBase< T >
int getElementCount () const
 Return the number of subfield elements (always one for scalars). More...
 
 FieldBase ()
 
 FieldBase (int)
 

Friends

class detail::Access
 
class BaseRecord
 
std::ostream & operator<< (std::ostream &os, Key< T > const &key)
 Stringification. More...
 

Additional Inherited Members

- Public Types inherited from lsst::afw::table::FieldBase< T >
typedef T Value
 the type returned by BaseRecord::get More...
 
typedef T & Reference
 the type returned by BaseRecord::operator[] (non-const) More...
 
typedef T const & ConstReference
 the type returned by BaseRecord::operator[] (const) More...
 
typedef T Element
 the type of subfields (the same as the type itself for scalars) More...
 
- Static Public Member Functions inherited from lsst::afw::table::FieldBase< T >
static std::string getTypeString ()
 Return a string description of the field type. More...
 
- Static Public Attributes inherited from lsst::afw::table::KeyBase< T >
static bool const HAS_NAMED_SUBFIELDS = false
 
- Protected Member Functions inherited from lsst::afw::table::FieldBase< T >
void stream (std::ostream &os) const
 Defines how Fields are printed. More...
 
Reference getReference (Element *p, ndarray::Manager::Ptr const &) const
 Used to implement BaseRecord::operator[] (non-const). More...
 
ConstReference getConstReference (Element const *p, ndarray::Manager::Ptr const &) const
 Used to implement BaseRecord::operator[] (const). More...
 
Value getValue (Element const *p, ndarray::Manager::Ptr const &) const
 Used to implement BaseRecord::get. More...
 
void setValue (Element *p, ndarray::Manager::Ptr const &, Value v) const
 Used to implement BaseRecord::set. More...
 
- Static Protected Member Functions inherited from lsst::afw::table::FieldBase< T >
static FieldBase makeDefault ()
 Needed to allow Keys to be default-constructed. More...
 

Detailed Description

template<typename T>
class lsst::afw::table::Key< T >

A class used as a handle to a particular field in a table.

All access to table data ultimately goes through Key objects, which know (via an internal offset) how to address and cast the internal data buffer of a record or table.

Keys can be obtained from a Schema by name:

schema.find("myfield").key

and are also returned when a new field is added. Compound and array keys also provide accessors to retrieve scalar keys to their elements (see the documentation for the KeyBase specializations), even though these element keys do not correspond to a field that exists in any Schema. For example:

Schema schema;
Key< Array<float> > arrayKey = schema.addField< Array<float> >("array", "docs for array", 5);
Key< Point<int> > pointKey = schema.addField< Point<int> >("point", "docs for point");
Key<float> elementKey = arrayKey[3];
Key<int> xKey = pointKey.getX();
std::shared_ptr<BaseTable> table = BaseTable::make(schema);
std::shared_ptr<BaseRecord> record = table.makeRecord();
assert(&record[arrayKey][3] == &record[elementKey3]);
assert(record.get(pointKey).getX() == record[xKey]);

Key inherits from FieldBase to allow a key for a dynamically-sized field to know its size without needing to specialize Key itself or hold a full Field object.

Definition at line 45 of file fwd.h.

Constructor & Destructor Documentation

template<typename T>
lsst::afw::table::Key< T >::Key ( )
inline

Default construct a field.

The new field will be invalid until a valid Key is assigned to it.

Definition at line 96 of file Key.h.

Member Function Documentation

template<typename T>
int lsst::afw::table::Key< T >::getOffset ( ) const
inline

Return the offset (in bytes) of this field within a record.

Definition at line 79 of file Key.h.

template<typename T>
bool lsst::afw::table::Key< T >::isValid ( ) const
inline

Return true if the key was initialized to valid offset.

This does not guarantee that a key is valid with any particular schema, or even that any schemas still exist in which this key is valid.

A key that is default constructed will always be invalid.

Definition at line 89 of file Key.h.

template<typename T>
template<typename OtherT >
bool lsst::afw::table::Key< T >::operator!= ( Key< OtherT > const &  other) const
inline

Equality comparison.

Two keys with different types are never equal. Keys with the same type are equal if they point to the same location in a table, regardless of what Schema they were constructed from (for instance, if a field has a different name in one Schema than another, but is otherwise the same, the two keys will be equal).

Definition at line 68 of file Key.h.

template<typename T>
bool lsst::afw::table::Key< T >::operator!= ( Key< T > const &  other) const
inline

Equality comparison.

Two keys with different types are never equal. Keys with the same type are equal if they point to the same location in a table, regardless of what Schema they were constructed from (for instance, if a field has a different name in one Schema than another, but is otherwise the same, the two keys will be equal).

Definition at line 75 of file Key.h.

template<typename T>
template<typename OtherT >
bool lsst::afw::table::Key< T >::operator== ( Key< OtherT > const &  other) const
inline

Equality comparison.

Two keys with different types are never equal. Keys with the same type are equal if they point to the same location in a table, regardless of what Schema they were constructed from (for instance, if a field has a different name in one Schema than another, but is otherwise the same, the two keys will be equal).

Definition at line 64 of file Key.h.

template<typename T>
bool lsst::afw::table::Key< T >::operator== ( Key< T > const &  other) const
inline

Equality comparison.

Two keys with different types are never equal. Keys with the same type are equal if they point to the same location in a table, regardless of what Schema they were constructed from (for instance, if a field has a different name in one Schema than another, but is otherwise the same, the two keys will be equal).

Definition at line 72 of file Key.h.

Friends And Related Function Documentation

template<typename T>
friend class BaseRecord
friend

Definition at line 106 of file Key.h.

template<typename T>
friend class detail::Access
friend

Definition at line 105 of file Key.h.

template<typename T>
std::ostream& operator<< ( std::ostream &  os,
Key< T > const &  key 
)
friend

Stringification.

Definition at line 99 of file Key.h.


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