lsst.afw
g3a5ebb7d8a+28b83bf6a5
Toggle main menu visibility
Loading...
Searching...
No Matches
include
lsst
afw
table
detail
Access.h
Go to the documentation of this file.
1
// -*- lsst-c++ -*-
2
#ifndef AFW_TABLE_DETAIL_Access_h_INCLUDED
3
#define AFW_TABLE_DETAIL_Access_h_INCLUDED
4
5
#include <cstring>
6
7
#include "ndarray/Manager.h"
8
#include "
lsst/afw/table/FieldBase.h
"
9
#include "
lsst/afw/table/Schema.h
"
10
#include "
lsst/afw/table/detail/SchemaImpl.h
"
11
12
namespace
lsst
{
13
namespace
afw
{
14
namespace
table
{
15
16
class
BaseRecord
;
17
class
BaseTable
;
18
19
namespace
detail
{
20
31
class
Access
final {
32
public
:
34
template
<
typename
T>
35
static
Key<typename Key<T>::Element
>
extractElement
(
KeyBase<T>
const
&kb,
std::size_t
n) {
36
if
(!
static_cast<
Key<T>
const
&
>
(kb).isValid()) {
37
throw
LSST_EXCEPT
(
38
pex::exceptions::LogicError
,
39
(boost::format(
40
"Cannot extract subfield key from invalid key of type '%s' "
41
"(most often this is caused by failing to setup centroid or shape slots)"
) %
42
Key<T>::getTypeString
())
43
.str());
44
}
45
return
Key<typename Key<T>::Element
>(
static_cast<
Key<T>
const
&
>
(kb).
getOffset
() +
46
n *
sizeof
(
typename
Key<T>::Element
));
47
}
48
50
template
<
typename
T>
51
static
Key<Array<T>
>
extractRange
(
KeyBase
<
Array<T>
>
const
&kb,
std::size_t
begin,
std::size_t
end) {
52
if
(!
static_cast<
Key<Array<T>
>
const
&>(kb).isValid()) {
53
throw
LSST_EXCEPT
(
pex::exceptions::LogicError
,
54
(boost::format(
"Cannot extract subfield key from invalid key of type '%s' "
) %
55
Key<T>::getTypeString
())
56
.str());
57
}
58
return
Key<Array<T>
>(
static_cast<
Key<Array<T>
>
const
&>(kb).
getOffset
() +
59
begin *
sizeof
(
typename
Key<T>::Element
),
60
end - begin);
61
}
62
64
template
<
typename
T>
65
static
Key<T>
makeKey
(
std::size_t
offset) {
66
return
Key<T>
(offset);
67
}
68
70
template
<
typename
T>
71
static
Key<T>
makeKey
(
Field<T>
const
&field,
std::size_t
offset) {
72
return
Key<T>
(offset, field);
73
}
74
76
static
Key<Flag>
makeKey
(
std::size_t
offset,
std::size_t
bit) {
return
Key<Flag>
(offset, bit); }
77
79
static
Key<std::string>
makeKeyString
(
std::size_t
offset,
std::size_t
size) {
return
Key<std::string>
(offset, size); }
80
82
template
<
typename
T>
83
static
Key<Array<T>
>
makeKeyArray
(
std::size_t
offset,
std::size_t
size) {
84
return
Key<Array<T>
>(offset, size);
85
}
86
88
static
void
padSchema
(
Schema
&schema,
std::size_t
bytes) {
89
schema._edit();
90
schema._impl->_recordSize += bytes;
91
}
92
};
93
}
// namespace detail
94
}
// namespace table
95
}
// namespace afw
96
}
// namespace lsst
97
98
#endif
// !AFW_TABLE_DETAIL_Access_h_INCLUDED
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
FieldBase.h
Schema.h
SchemaImpl.h
lsst::afw::table::Array
Tag types used to declare specialized field types.
Definition
misc.h:31
lsst::afw::table::BaseRecord
Base class for all records.
Definition
BaseRecord.h:31
lsst::afw::table::BaseTable
Base class for all tables.
Definition
BaseTable.h:61
lsst::afw::table::KeyBase
A base class for Key that allows subfield keys to be extracted for some field types.
Definition
KeyBase.h:20
lsst::afw::table::Key
A class used as a handle to a particular field in a table.
Definition
Key.h:53
lsst::afw::table::Key::getOffset
std::size_t getOffset() const noexcept
Return the offset (in bytes) of this field within a record.
Definition
Key.h:87
lsst::afw::table::Schema
Defines the fields and offsets for a table.
Definition
Schema.h:51
lsst::afw::table::detail::Access
Definition
Access.h:31
lsst::afw::table::detail::Access::extractElement
static Key< typename Key< T >::Element > extractElement(KeyBase< T > const &kb, std::size_t n)
Definition
Access.h:35
lsst::afw::table::detail::Access::extractRange
static Key< Array< T > > extractRange(KeyBase< Array< T > > const &kb, std::size_t begin, std::size_t end)
Definition
Access.h:51
lsst::afw::table::detail::Access::makeKey
static Key< T > makeKey(std::size_t offset)
Definition
Access.h:65
lsst::afw::table::detail::Access::padSchema
static void padSchema(Schema &schema, std::size_t bytes)
Definition
Access.h:88
lsst::afw::table::detail::Access::makeKey
static Key< T > makeKey(Field< T > const &field, std::size_t offset)
Definition
Access.h:71
lsst::afw::table::detail::Access::makeKeyArray
static Key< Array< T > > makeKeyArray(std::size_t offset, std::size_t size)
Definition
Access.h:83
lsst::afw::table::detail::Access::makeKey
static Key< Flag > makeKey(std::size_t offset, std::size_t bit)
Definition
Access.h:76
lsst::afw::table::detail::Access::makeKeyString
static Key< std::string > makeKeyString(std::size_t offset, std::size_t size)
Definition
Access.h:79
lsst::pex::exceptions::LogicError
lsst::afw::table::detail
Definition
BaseColumnView.h:13
lsst::afw::table
Definition
table.dox:3
lsst::afw
Definition
imageAlgorithm.dox:1
lsst
std::size_t
lsst::afw::table::FieldBase::getTypeString
static std::string getTypeString()
Return a string description of the field type.
Definition
FieldBase.cc:56
lsst::afw::table::FieldBase::Element
T Element
the type of subfields (the same as the type itself for scalars)
Definition
FieldBase.h:45
lsst::afw::table::Field
A description of a field in a table.
Definition
Field.h:24
Generated on
for lsst.afw by
1.17.0