lsst.afw  18.1.0-14-gac42dcd43+2
Public Types | Public Member Functions | Static Public Member Functions | List of all members
lsst::afw::table::ArrayKey< T > Class Template Reference

A FunctorKey used to get or set a ndarray::Array from a sequence of scalar Keys. More...

#include <arrays.h>

Inheritance diagram for lsst::afw::table::ArrayKey< T >:
lsst::afw::table::FunctorKey< ndarray::Array< T const, 1, 1 > > lsst::afw::table::ReferenceFunctorKey< ndarray::ArrayRef< T, 1, 1 > > lsst::afw::table::ConstReferenceFunctorKey< ndarray::ArrayRef< T const, 1, 1 > > lsst::afw::table::OutputFunctorKey< ndarray::Array< T const, 1, 1 > > lsst::afw::table::InputFunctorKey< ndarray::Array< T const, 1, 1 > >

Public Types

using Value = ndarray::Array< T const, 1, 1 >
 The data type for get and set. More...
 

Public Member Functions

 ArrayKey () noexcept
 Default constructor; instance will not be usable unless subsequently assigned to. More...
 
 ArrayKey (std::vector< Key< T > > const &keys)
 Construct from a vector of scalar Keys. More...
 
 ArrayKey (Key< Array< T > > const &other) noexcept
 Construct from a compound Key< Array<T> > More...
 
 ArrayKey (SubSchema const &s)
 Construct from a subschema, assuming *_0, *_1, *_2, etc. More...
 
 ArrayKey (ArrayKey const &) noexcept
 
 ArrayKey (ArrayKey &&) noexcept
 
ArrayKey & operator= (ArrayKey const &) noexcept
 
ArrayKey & operator= (ArrayKey &&) noexcept
 
 ~ArrayKey () noexcept override
 
int getSize () const noexcept
 Return the number of elements in the array. More...
 
ndarray::Array< T const, 1, 1 > get (BaseRecord const &record) const override
 Get an array from the given record. More...
 
void set (BaseRecord &record, ndarray::Array< T const, 1, 1 > const &value) const override
 Set an array in the given record. More...
 
ndarray::ArrayRef< T, 1, 1 > getReference (BaseRecord &record) const override
 Get non-const reference array from the given record. More...
 
ndarray::ArrayRef< T const, 1, 1 > getConstReference (BaseRecord const &record) const override
 Get const reference array from the given record. More...
 
std::size_t hash_value () const noexcept
 Return a hash of this object. More...
 
bool isValid () const noexcept
 Return True if the FunctorKey contains valid scalar keys. More...
 
Key< T > operator[] (int i) const
 Return a scalar Key for an element of the array. More...
 
ArrayKey slice (int begin, int end) const
 Return a FunctorKey corresponding to a range of elements. More...
 
bool operator== (ArrayKey< T > const &other) const noexcept
 Compare the FunctorKey for equality with another, using the underlying scalar Keys. More...
 
bool operator!= (ArrayKey< T > const &other) const noexcept
 Compare the FunctorKey for equality with another, using the underlying scalar Keys. More...
 

Static Public Member Functions

static ArrayKey addFields (Schema &schema, std::string const &name, std::string const &doc, std::string const &unit, std::vector< T > const &docData)
 Add an array of fields to a Schema, and return an ArrayKey that points to them. More...
 
static ArrayKey addFields (Schema &schema, std::string const &name, std::string const &doc, std::string const &unit, int size)
 Add an array of fields to a Schema, and return an ArrayKey that points to them. More...
 

Detailed Description

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

A FunctorKey used to get or set a ndarray::Array from a sequence of scalar Keys.

ArrayKey operates on the convention that arrays are defined by a set of contiguous scalar fields (i.e. added to the Schema in order, with no interruption) of the same type, with a common field name prefix and "_0", "_1" etc. suffixes.

Definition at line 43 of file arrays.h.

Member Typedef Documentation

◆ Value

using lsst::afw::table::FunctorKey< ndarray::Array< T const, 1, 1 > >::Value = ndarray::Array< T const, 1, 1 >
inherited

The data type for get and set.

Definition at line 77 of file FunctorKey.h.

Constructor & Destructor Documentation

◆ ArrayKey() [1/6]

template<typename T>
lsst::afw::table::ArrayKey< T >::ArrayKey ( )
inlinenoexcept

Default constructor; instance will not be usable unless subsequently assigned to.

Definition at line 78 of file arrays.h.

◆ ArrayKey() [2/6]

template<typename T >
lsst::afw::table::ArrayKey< T >::ArrayKey ( std::vector< Key< T > > const &  keys)
explicit

Construct from a vector of scalar Keys.

Definition at line 66 of file arrays.cc.

◆ ArrayKey() [3/6]

template<typename T >
lsst::afw::table::ArrayKey< T >::ArrayKey ( Key< Array< T > > const &  other)
explicitnoexcept

Construct from a compound Key< Array<T> >

Key< Array<T> > is now deprecated in favor of ArrayKey; this factory function is intended to aid in the transition.

Definition at line 78 of file arrays.cc.

◆ ArrayKey() [4/6]

template<typename T >
lsst::afw::table::ArrayKey< T >::ArrayKey ( SubSchema const &  s)

Construct from a subschema, assuming *_0, *_1, *_2, etc.

subfields

If a schema has "a_0", "a_1", and "a_2" fields, this constructor allows you to construct a 3-element ArrayKey via:

ArrayKey<T> k(schema["a"]);

Definition at line 81 of file arrays.cc.

◆ ArrayKey() [5/6]

template<typename T >
lsst::afw::table::ArrayKey< T >::ArrayKey ( ArrayKey< T > const &  )
defaultnoexcept

◆ ArrayKey() [6/6]

template<typename T >
lsst::afw::table::ArrayKey< T >::ArrayKey ( ArrayKey< T > &&  )
defaultnoexcept

◆ ~ArrayKey()

template<typename T >
lsst::afw::table::ArrayKey< T >::~ArrayKey ( )
overridedefaultnoexcept

Member Function Documentation

◆ addFields() [1/2]

template<typename T >
ArrayKey< T > lsst::afw::table::ArrayKey< T >::addFields ( Schema &  schema,
std::string const &  name,
std::string const &  doc,
std::string const &  unit,
std::vector< T > const &  docData 
)
static

Add an array of fields to a Schema, and return an ArrayKey that points to them.

Parameters
[in,out]schemaSchema to add fields to.
[in]nameName prefix for all fields; "_0", "_1", etc. will be appended to this to form the full field names.
[in]docString used as the documentation for the fields. Should include a single boost::format template string, which will be substituted with the appropriate element from the docData array to form the full documentation string.
[in]unitString used as the unit for all fields.
[in]docDataVector of values substituted into the doc fields. The length of the vector determines the number of fields added.

Definition at line 35 of file arrays.cc.

◆ addFields() [2/2]

template<typename T >
ArrayKey< T > lsst::afw::table::ArrayKey< T >::addFields ( Schema &  schema,
std::string const &  name,
std::string const &  doc,
std::string const &  unit,
int  size 
)
static

Add an array of fields to a Schema, and return an ArrayKey that points to them.

Parameters
[in,out]schemaSchema to add fields to.
[in]nameName prefix for all fields; "_0", "_1", etc. will be appended to this to form the full field names.
[in]docString used as the documentation for the fields.
[in]unitString used as the unit for all fields.
[in]sizeNumber of fields to add.

Definition at line 51 of file arrays.cc.

◆ get()

template<typename T >
ndarray::Array< T const, 1, 1 > lsst::afw::table::ArrayKey< T >::get ( BaseRecord const &  record) const
overridevirtual

Get an array from the given record.

Implements lsst::afw::table::OutputFunctorKey< ndarray::Array< T const, 1, 1 > >.

Definition at line 109 of file arrays.cc.

◆ getConstReference()

template<typename T >
ndarray::ArrayRef< T const, 1, 1 > lsst::afw::table::ArrayKey< T >::getConstReference ( BaseRecord const &  record) const
overridevirtual

Get const reference array from the given record.

Implements lsst::afw::table::ConstReferenceFunctorKey< ndarray::ArrayRef< T const, 1, 1 > >.

Definition at line 129 of file arrays.cc.

◆ getReference()

template<typename T >
ndarray::ArrayRef< T, 1, 1 > lsst::afw::table::ArrayKey< T >::getReference ( BaseRecord &  record) const
overridevirtual

Get non-const reference array from the given record.

Implements lsst::afw::table::ReferenceFunctorKey< ndarray::ArrayRef< T, 1, 1 > >.

Definition at line 123 of file arrays.cc.

◆ getSize()

template<typename T>
int lsst::afw::table::ArrayKey< T >::getSize ( ) const
inlinenoexcept

Return the number of elements in the array.

Definition at line 108 of file arrays.h.

◆ hash_value()

template<typename T>
std::size_t lsst::afw::table::ArrayKey< T >::hash_value ( ) const
inlinenoexcept

Return a hash of this object.

Definition at line 131 of file arrays.h.

◆ isValid()

template<typename T>
bool lsst::afw::table::ArrayKey< T >::isValid ( ) const
inlinenoexcept

Return True if the FunctorKey contains valid scalar keys.

Definition at line 137 of file arrays.h.

◆ operator!=()

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

Compare the FunctorKey for equality with another, using the underlying scalar Keys.

Definition at line 127 of file arrays.h.

◆ operator=() [1/2]

template<typename T >
ArrayKey< T > & lsst::afw::table::ArrayKey< T >::operator= ( ArrayKey< T > const &  )
defaultnoexcept

◆ operator=() [2/2]

template<typename T >
ArrayKey< T > & lsst::afw::table::ArrayKey< T >::operator= ( ArrayKey< T > &&  )
defaultnoexcept

◆ operator==()

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

Compare the FunctorKey for equality with another, using the underlying scalar Keys.

Definition at line 124 of file arrays.h.

◆ operator[]()

template<typename T >
Key< T > lsst::afw::table::ArrayKey< T >::operator[] ( int  i) const

Return a scalar Key for an element of the array.

Definition at line 135 of file arrays.cc.

◆ set()

template<typename T >
void lsst::afw::table::ArrayKey< T >::set ( BaseRecord &  record,
ndarray::Array< T const, 1, 1 > const &  value 
) const
overridevirtual

Set an array in the given record.

Implements lsst::afw::table::InputFunctorKey< ndarray::Array< T const, 1, 1 > >.

Definition at line 115 of file arrays.cc.

◆ slice()

template<typename T >
ArrayKey< T > lsst::afw::table::ArrayKey< T >::slice ( int  begin,
int  end 
) const

Return a FunctorKey corresponding to a range of elements.

Definition at line 143 of file arrays.cc.


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