Template Class Key¶
Defined in File fwd.h
Inheritance Relationships¶
Base Types¶
public lsst::afw::table::KeyBase< T >
(Template Class KeyBase)public lsst::afw::table::FieldBase< T >
(Template Struct FieldBase)
Class Documentation¶
-
template<typename
T
>
classKey
: public lsst::afw::table::KeyBase<T>, public lsst::afw::table::FieldBase<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.
Unnamed Group
-
template<typename
OtherT
>
booloperator==
(Key<OtherT> const &other) const¶ 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).
-
bool
operator==
(Key const &other) const¶
-
bool
operator!=
(Key const &other) const¶
Public Functions
-
std::size_t
hash_value
() const¶ Return a hash of this object.
-
int
getOffset
() const¶ Return the offset (in bytes) of this field within a record.
-
bool
isValid
() const¶ 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.
-
Key
()¶ Default construct a field.
The new field will be invalid until a valid Key is assigned to it.
-
Key &
operator=
(Key const&)¶
-
Key &
operator=
(Key&&)¶
-
~Key
()¶
Friends
-
friend
lsst::afw::table::Key::detail::Access
-
std::ostream &
operator<<
(std::ostream &os, Key<T> const &key)¶ Stringification.
-
template<typename