Template Struct FieldBase< Array< U > >¶
Defined in File FieldBase.h
Struct Documentation¶
-
template<typename
U
>
structFieldBase
<Array<U>> Field base class specialization for arrays.
The Array tag is used for both fixed-length (same size in every record, accessible via ColumnView) and variable-length arrays; variable-length arrays are initialized with a size of 0. Ideally, we’d use complete different tag classes for those two very different types, but boost::variant and boost::mpl put a limit of 20 on the number of field types, and we’re running out. In a future reimplementation of afw::table, we should fix this.
Public Types
-
typedef ndarray::Array<U const, 1, 1>
Value
the type returned by BaseRecord::get
-
typedef ndarray::ArrayRef<U, 1, 1>
Reference
the type returned by BaseRecord::operator[]
-
typedef ndarray::ArrayRef<U const, 1, 1>
ConstReference
the type returned by BaseRecord::operator[] (const)
-
typedef U
Element
the type of subfields and array elements
Public Functions
-
FieldBase
(int size = 0) Construct a FieldBase with the given size.
A size == 0 indicates a variable-length array. Negative sizes are not permitted.
This constructor is implicit with a default so it can be used in the Field constructor (as if it were an int argument) without specializing Field. In other words, it allows one to construct a 25-element array field like this:
Field< Array<float> >("name", "documentation", 25);
…even though the third argument to the Field constructor takes a FieldBase, not an int.
-
FieldBase
(FieldBase const&)
-
FieldBase
(FieldBase&&)
-
FieldBase &
operator=
(FieldBase const&)
-
FieldBase &
operator=
(FieldBase&&)
-
~FieldBase
()
-
int
getElementCount
() const Return the number of subfield elements (equal to the size of the array), or 0 for a variable-length array.
-
int
getSize
() const¶ Return the size of the array (equal to the number of subfield elements), or 0 for a variable-length array.
-
bool
isVariableLength
() const¶ Return true if the field is variable-length (each record can have a different size array).
Public Static Functions
-
static std::string
getTypeString
() Return a string description of the field type.
Protected Functions
-
void
stream
(std::ostream &os) const Defines how Fields are printed.
-
Reference
getReference
(Element *p, ndarray::Manager::Ptr const &m) const Used to implement BaseRecord::operator[] (non-const).
-
ConstReference
getConstReference
(Element const *p, ndarray::Manager::Ptr const &m) const Used to implement BaseRecord::operator[] (const).
-
Value
getValue
(Element const *p, ndarray::Manager::Ptr const &m) const Used to implement BaseRecord::get.
-
void
setValue
(Element *p, ndarray::Manager::Ptr const&, ndarray::Array<Element, 1, 1> const &value) const¶ Used to implement BaseRecord::set; accepts only non-const arrays of the right type. Fixed-length arrays are handled by copying the data from
value
top
throughp + _size
. Variable-length arrays are handled by settingp
to the address ofvalue
, an ndarray, hence a shallow copy (ndarray arrays are reference-counted so this will not leak memory). If you want deep assignment of variable-length data, use operator[] to get a reference and assign to that.
-
template<typename
Derived
>
voidsetValue
(Element *p, ndarray::Manager::Ptr const&, ndarray::ExpressionBase<Derived> const &value) const¶ Used to implement BaseRecord::set; accepts any ndarray expression.
Protected Static Functions
-
static FieldBase
makeDefault
() Needed to allow Keys to be default-constructed.
-
typedef ndarray::Array<U const, 1, 1>