LSST Applications g070148d5b3+33e5256705,g0d53e28543+25c8b88941,g0da5cf3356+2dd1178308,g1081da9e2a+62d12e78cb,g17e5ecfddb+7e422d6136,g1c76d35bf8+ede3a706f7,g295839609d+225697d880,g2e2c1a68ba+cc1f6f037e,g2ffcdf413f+853cd4dcde,g38293774b4+62d12e78cb,g3b44f30a73+d953f1ac34,g48ccf36440+885b902d19,g4b2f1765b6+7dedbde6d2,g5320a0a9f6+0c5d6105b6,g56b687f8c9+ede3a706f7,g5c4744a4d9+ef6ac23297,g5ffd174ac0+0c5d6105b6,g6075d09f38+66af417445,g667d525e37+2ced63db88,g670421136f+2ced63db88,g71f27ac40c+2ced63db88,g774830318a+463cbe8d1f,g7876bc68e5+1d137996f1,g7985c39107+62d12e78cb,g7fdac2220c+0fd8241c05,g96f01af41f+368e6903a7,g9ca82378b8+2ced63db88,g9d27549199+ef6ac23297,gabe93b2c52+e3573e3735,gb065e2a02a+3dfbe639da,gbc3249ced9+0c5d6105b6,gbec6a3398f+0c5d6105b6,gc9534b9d65+35b9f25267,gd01420fc67+0c5d6105b6,geee7ff78d7+a14128c129,gf63283c776+ede3a706f7,gfed783d017+0c5d6105b6,w.2022.47
LSST Data Management Base Package
Loading...
Searching...
No Matches
KeyBase.cc
Go to the documentation of this file.
1// -*- lsst-c++ -*-
2
3#include "boost/preprocessor/seq/for_each.hpp"
4#include "boost/preprocessor/tuple/to_seq.hpp"
5
10
11namespace lsst {
12namespace afw {
13namespace table {
14
16 return detail::Access::extractElement(*this, 0);
17}
18
19template <typename U>
20std::vector<U> KeyBase<Array<U>>::extractVector(BaseRecord const &record) const {
21 Key<Array<U>> const *self = static_cast<Key<Array<U>> const *>(this);
22 std::vector<U> result(self->getSize());
23 typename Key<Array<U>>::ConstReference array = record[*self];
24 std::copy(array.begin(), array.end(), result.begin());
25 return result;
26}
27
28template <typename U>
29void KeyBase<Array<U>>::assignVector(BaseRecord &record, std::vector<U> const &values) const {
30 Key<Array<U>> const *self = static_cast<Key<Array<U>> const *>(this);
31 std::copy(values.begin(), values.end(), record[*self].begin());
32}
33
34template <typename U>
35Key<U> KeyBase<Array<U>>::operator[](std::size_t i) const {
36 Key<Array<U>> const *self = static_cast<Key<Array<U>> const *>(this);
37 if (self->isVariableLength()) {
39 "Cannot get Keys to elements of variable-length arrays.");
40 }
41 if (i >= self->getSize()) {
42 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError, "Array key index out of range.");
43 }
44 return detail::Access::extractElement(*this, i);
45}
46
47template <typename U>
49 Key<Array<U>> const *self = static_cast<Key<Array<U>> const *>(this);
50 if (self->isVariableLength()) {
52 "Cannot get Keys to slices of variable-length arrays.");
53 }
54 if (begin > self->getSize()) {
55 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError, "Array key begin index out of range.");
56 }
57 if (end > self->getSize()) {
58 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError, "Array key end index out of range.");
59 }
60 return detail::Access::extractRange(*this, begin, end);
61}
62
63//----- Explicit instantiation ------------------------------------------------------------------------------
64
65#define INSTANTIATE_KEY(r, data, elem) template class KeyBase<elem>;
66
69} // namespace table
70} // namespace afw
71} // namespace lsst
py::object result
Definition: _schema.cc:429
int end
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
#define INSTANTIATE_KEY(r, data, elem)
Definition: KeyBase.cc:65
T begin(T... args)
Base class for all records.
Definition: BaseRecord.h:31
A base class for Key that allows subfield keys to be extracted for some field types.
Definition: KeyBase.h:20
A class used as a handle to a particular field in a table.
Definition: Key.h:53
static Key< typename Key< T >::Element > extractElement(KeyBase< T > const &kb, std::size_t n)
Definition: Access.h:35
static Key< Array< T > > extractRange(KeyBase< Array< T > > const &kb, std::size_t begin, std::size_t end)
Definition: Access.h:51
Reports attempts to exceed implementation-defined length limits for some classes.
Definition: Runtime.h:76
Reports errors in the logical structure of the program.
Definition: Runtime.h:46
T copy(T... args)
T end(T... args)
BOOST_PP_SEQ_FOR_EACH(INSTANTIATE_COLUMNVIEW_SCALAR, _, BOOST_PP_TUPLE_TO_SEQ(AFW_TABLE_SCALAR_FIELD_TYPE_N, AFW_TABLE_SCALAR_FIELD_TYPE_TUPLE)) BOOST_PP_SEQ_FOR_EACH(INSTANTIATE_COLUMNVIEW_ARRAY
#define AFW_TABLE_FIELD_TYPE_N
Definition: types.h:38
#define AFW_TABLE_FIELD_TYPE_TUPLE
Definition: types.h:43