lsst.afw
g3a5ebb7d8a+28b83bf6a5
Toggle main menu visibility
Loading...
Searching...
No Matches
include
lsst
afw
table
Key.h
Go to the documentation of this file.
1
// -*- lsst-c++ -*-
2
#ifndef AFW_TABLE_Key_h_INCLUDED
3
#define AFW_TABLE_Key_h_INCLUDED
4
5
#include "
lsst/cpputils/hashCombine.h
"
6
7
#include "
lsst/afw/table/FieldBase.h
"
8
#include "
lsst/afw/table/Flag.h
"
9
#include "
lsst/afw/table/KeyBase.h
"
10
11
namespace
lsst
{
12
namespace
afw
{
13
namespace
table
{
14
15
namespace
detail
{
16
17
class
Access
;
18
19
}
// namespace detail
20
52
template
<
typename
T>
53
class
Key
:
public
KeyBase
<T>,
public
FieldBase
<T> {
54
public
:
56
65
template
<
typename
OtherT>
66
bool
operator==
(
Key<OtherT>
const
& other)
const
noexcept
{
67
return
false
;
68
}
69
template
<
typename
OtherT>
70
bool
operator!=
(
Key<OtherT>
const
& other)
const
noexcept
{
71
return
true
;
72
}
73
74
bool
operator==
(
Key
const
& other)
const
noexcept
{
75
return
_offset == other._offset && this->
getElementCount
() == other.getElementCount();
76
}
77
bool
operator!=
(
Key
const
& other)
const
noexcept
{
return
!this->
operator==
(other); }
79
81
std::size_t
hash_value
() const noexcept {
82
// Completely arbitrary seed
83
return
cpputils::hashCombine
(17, _offset, this->
getElementCount
());
84
}
85
87
std::size_t
getOffset
() const noexcept {
return
_offset; }
88
97
bool
isValid
() const noexcept {
return
_valid; }
98
104
Key
() noexcept :
FieldBase
<T>(
FieldBase
<T>::
makeDefault
()), _offset(0), _valid(false) {}
105
106
Key
(
Key
const
&)
noexcept
=
default
;
107
Key
(
Key
&&) noexcept = default;
108
Key
& operator=(
Key
const&) noexcept = default;
109
Key
& operator=(
Key
&&) noexcept = default;
110
~
Key
() noexcept = default;
111
113
inline friend
std
::ostream& operator<<(
std
::ostream& os,
Key
<T> const& key) {
114
return
os <<
"Key<"
<<
Key<T>::getTypeString
() <<
">(offset="
<< key.getOffset()
115
<<
", nElements="
<< key.getElementCount() <<
")"
;
116
}
117
118
private
:
119
friend
class
detail::Access
;
120
friend
class
BaseRecord
;
121
122
explicit
Key
(
std::size_t
offset,
FieldBase<T>
const
& fb =
FieldBase<T>
()) noexcept
123
:
FieldBase
<T>(fb), _offset(offset), _valid(true) {}
124
125
std::size_t
_offset;
126
bool
_valid;
127
};
128
}
// namespace table
129
}
// namespace afw
130
}
// namespace lsst
131
132
namespace
std
{
133
template
<
typename
T>
134
struct
hash
<
lsst
::afw::table::Key<T>> {
135
using
argument_type
=
lsst::afw::table::Key<T>
;
136
using
result_type
=
size_t
;
137
size_t
operator()
(
argument_type
const
& obj)
const
noexcept
{
return
obj.hash_value(); }
138
};
139
}
// namespace std
140
141
#endif
// !AFW_TABLE_Key_h_INCLUDED
FieldBase.h
Flag.h
KeyBase.h
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::operator==
bool operator==(Key< OtherT > const &other) const noexcept
Equality comparison.
Definition
Key.h:66
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::Key::operator!=
bool operator!=(Key const &other) const noexcept
Definition
Key.h:77
lsst::afw::table::Key::Key
Key() noexcept
Default construct a field.
Definition
Key.h:104
lsst::afw::table::Key::Key
Key(Key &&) noexcept=default
lsst::afw::table::Key::isValid
bool isValid() const noexcept
Return true if the key was initialized to valid offset.
Definition
Key.h:97
lsst::afw::table::Key::hash_value
std::size_t hash_value() const noexcept
Return a hash of this object.
Definition
Key.h:81
lsst::afw::table::Key::operator==
bool operator==(Key const &other) const noexcept
Definition
Key.h:74
lsst::afw::table::Key< afw::table::Flag >::BaseRecord
friend class BaseRecord
Definition
Key.h:120
lsst::afw::table::Key::operator!=
bool operator!=(Key< OtherT > const &other) const noexcept
Definition
Key.h:70
lsst::afw::table::Key::Key
Key(Key const &) noexcept=default
lsst::afw::table::detail::Access
Definition
Access.h:31
hashCombine.h
std::hash< lsst::afw::table::Key< T > >::hash
T hash(T... args)
lsst::afw::table::detail
Definition
BaseColumnView.h:13
lsst::afw::table
Definition
table.dox:3
lsst::afw
Definition
imageAlgorithm.dox:1
lsst::cpputils::hashCombine
std::size_t hashCombine(std::size_t seed) noexcept
lsst
std
STL namespace.
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::getElementCount
std::size_t getElementCount() const noexcept
Return the number of subfield elements (always one for scalars).
Definition
FieldBase.h:48
lsst::afw::table::FieldBase::FieldBase
FieldBase()=default
lsst::afw::table::Key< afw::table::Flag >::makeDefault
static FieldBase makeDefault() noexcept
Definition
FieldBase.h:69
std::hash< lsst::afw::table::Key< T > >::argument_type
lsst::afw::table::Key< T > argument_type
Definition
Key.h:135
std::hash< lsst::afw::table::Key< T > >::operator()
size_t operator()(argument_type const &obj) const noexcept
Definition
Key.h:137
std::hash< lsst::afw::table::Key< T > >::result_type
size_t result_type
Definition
Key.h:136
Generated on
for lsst.afw by
1.17.0