2 #ifndef AFW_TABLE_FieldBase_h_INCLUDED
3 #define AFW_TABLE_FieldBase_h_INCLUDED
8 #include "boost/mpl/vector.hpp"
9 #include "boost/preprocessor/punctuation/paren.hpp"
20 namespace lsst {
namespace afw {
namespace table {
32 return (i < j) ? (i + j*(j+1)/2) : (j + i*(i+1)/2);
37 return size * (size + 1) / 2;
61 #ifndef SWIG_BUG_3465431_FIXED
68 lsst::pex::exceptions::LogicError,
69 "Constructor disabled (it only appears to exist as a workaround for a SWIG bug)."
80 void stream(std::ostream & os)
const {}
105 template <
typename U>
133 lsst::pex::exceptions::LogicError,
134 "A non-negative size must be provided when constructing an array field."
156 void stream(std::ostream & os)
const { os <<
", size=" << _size; }
160 if (isVariableLength()) {
168 if (isVariableLength()) {
176 if (isVariableLength()) {
189 if (isVariableLength()) {
192 setValueDeep(p, value);
197 template <
typename Derived>
201 if (isVariableLength()) {
203 lsst::pex::exceptions::LogicError,
204 "Assignment to a variable-length array must use a non-const array of the correct type."
207 setValueDeep(p, value);
212 template <
typename Derived>
214 if (value.template getSize<0>() != _size) {
216 lsst::pex::exceptions::LengthError,
217 "Incorrect size in array field assignment."
220 for (
int i = 0; i < _size; ++i) p[i] = value[i];
272 void stream(std::ostream & os)
const { os <<
", size=" << _size; }
296 #endif // !AFW_TABLE_FieldBase_h_INCLUDED
A proxy class for Array with deep assignment operators.
int getSize() const
Return the maximum length of the string, including a null terminator (equal to the number of subfield...
Field base class default implementation (used for numeric scalars and Angle).
An include file to include the header files for lsst::afw::geom.
char const * ConstReference
the type returned by BaseRecord::operator[] (const)
static FieldBase makeDefault()
Needed to allow Keys to be default-constructed.
int getElementCount() const
Return the number of subfield elements (equal to the size of the array).
void stream(std::ostream &os) const
Defines how Fields are printed.
static FieldBase makeDefault()
Needed to allow Keys to be default-constructed.
Reference getReference(Element *p, ndarray::Manager::Ptr const &m) const
Used to implement RecordBase::operator[] (non-const).
U Element
the type of subfields and array elements
detail::ExternalInitializer< T, N, Owner > external(T *data, Vector< int, N > const &shape, Vector< int, N > const &strides, Owner const &owner)
Create an expression that initializes an Array with externally allocated memory.
void setValueDeep(Element *p, ndarray::ExpressionBase< Derived > const &value) const
void setValue(Element *p, ndarray::Manager::Ptr const &, Value v) const
Used to implement RecordBase::set.
ConstReference getConstReference(Element const *p, ndarray::Manager::Ptr const &m) const
Used to implement RecordBase::operator[] (const).
int computeCovariancePackedSize(int size)
Defines the packed size of a covariance matrices.
T const & ConstReference
the type returned by BaseRecord::operator[] (const)
static std::string getTypeString()
Return a string description of the field type.
Value getValue(Element const *p, ndarray::Manager::Ptr const &) const
Used to implement RecordBase::get.
int getElementCount() const
Return the number of subfield elements (always one for scalars).
boost::intrusive_ptr< Manager > Ptr
std::string Value
the type returned by BaseRecord::get
T Element
the type of subfields (the same as the type itself for scalars)
int getElementCount() const
Return the number of subfield elements (equal to the size of the string, including a null terminator)...
ConstReference getConstReference(Element const *p, ndarray::Manager::Ptr const &) const
Used to implement RecordBase::operator[] (const).
int indexCovariance(int i, int j)
Defines the ordering of packed covariance matrices.
Vector< T, N > makeVector(T v1, T v2,..., T vN)
Variadic constructor for Vector.
int getSize() const
Return the size of the array (equal to the number of subfield elements).
Tag types used to declare specialized field types.
Reference getReference(Element *p, ndarray::Manager::Ptr const &m) const
Used to implement RecordBase::operator[] (non-const).
T Value
the type returned by BaseRecord::get
void setValue(Element *p, ndarray::Manager::Ptr const &, ndarray::ExpressionBase< Derived > const &value) const
Used to implement RecordBase::set; accepts any ndarray expression.
void setValue(Element *p, ndarray::Manager::Ptr const &, ndarray::Array< Element, 1, 1 > const &value) const
#define LSST_EXCEPT(type,...)
A multidimensional strided array.
ndarray::ArrayRef< U const, 1, 1 > ConstReference
the type returned by BaseRecord::operator[] (const)
FieldBase(int size=0)
Construct a FieldBase with the given size.
T & Reference
the type returned by BaseRecord::operator[] (non-const)
void stream(std::ostream &os) const
Defines how Fields are printed.
char * Reference
the type returned by BaseRecord::operator[]
ndarray::ArrayRef< U, 1, 1 > Reference
the type returned by BaseRecord::operator[]
void stream(std::ostream &os) const
Defines how Fields are printed.
ConstReference getConstReference(Element const *p, ndarray::Manager::Ptr const &m) const
Used to implement RecordBase::operator[] (const).
ndarray::Array< U const, 1, 1 > Value
the type returned by BaseRecord::get
bool isVariableLength() const
Return true if the field is variable-length (each record can have a different size array)...
Reference getReference(Element *p, ndarray::Manager::Ptr const &) const
Used to implement RecordBase::operator[] (non-const).
Value getValue(Element const *p, ndarray::Manager::Ptr const &m) const
Used to implement RecordBase::get.
static FieldBase makeDefault()
Needed to allow Keys to be default-constructed.
char Element
the type of subfields and array elements
Include files required for standard LSST Exception handling.
CRTP base class for all multidimensional expressions.