LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
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
A base class for image defects.
#define AFW_TABLE_FIELD_TYPE_N
Definition: types.h:38
#define AFW_TABLE_FIELD_TYPE_TUPLE
Definition: types.h:43