lsst.afw  15.0-21-g91b8abf62
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 
6 #include "lsst/afw/table/Flag.h"
8 
9 namespace lsst {
10 namespace afw {
11 namespace table {
12 
13 namespace detail {
14 
15 class Access;
16 
17 } // namespace detail
18 
50 template <typename T>
51 class Key : public KeyBase<T>, public FieldBase<T> {
52 public:
54 
63  template <typename OtherT>
64  bool operator==(Key<OtherT> const& other) const {
65  return false;
66  }
67  template <typename OtherT>
68  bool operator!=(Key<OtherT> const& other) const {
69  return true;
70  }
71 
72  bool operator==(Key const& other) const {
73  return _offset == other._offset && this->getElementCount() == other.getElementCount();
74  }
75  bool operator!=(Key const& other) const { return !this->operator==(other); }
77 
79  int getOffset() const { return _offset; }
80 
89  bool isValid() const { return _offset >= 0; }
90 
96  Key() : FieldBase<T>(FieldBase<T>::makeDefault()), _offset(-1) {}
97 
98  Key(Key const &) = default;
99  Key(Key &&) = default;
100  Key & operator=(Key const &) = default;
101  Key & operator=(Key &&) = default;
102  ~Key() = default;
103 
105  inline friend std::ostream& operator<<(std::ostream& os, Key<T> const& key) {
106  return os << "Key<" << Key<T>::getTypeString() << ">(offset=" << key.getOffset()
107  << ", nElements=" << key.getElementCount() << ")";
108  }
109 
110 private:
111  friend class detail::Access;
112  friend class BaseRecord;
113 
114  explicit Key(int offset, FieldBase<T> const& fb = FieldBase<T>()) : FieldBase<T>(fb), _offset(offset) {}
115 
116  int _offset;
117 };
118 }
119 }
120 } // namespace lsst::afw::table
121 
122 #endif // !AFW_TABLE_Key_h_INCLUDED
Field base class default implementation (used for numeric scalars and Angle).
Definition: FieldBase.h:44
bool operator!=(Key< OtherT > const &other) const
Equality comparison.
Definition: Key.h:68
int getOffset() const
Return the offset (in bytes) of this field within a record.
Definition: Key.h:79
bool operator==(CoordKey const &lhs, CoordKey const &rhs)
Compare CoordKeys for equality using the constituent Keys.
bool operator==(Key< OtherT > const &other) const
Equality comparison.
Definition: Key.h:64
ItemVariant const * other
Definition: Schema.cc:55
bool isValid() const
Return true if the key was initialized to valid offset.
Definition: Key.h:89
bool operator==(Key const &other) const
Equality comparison.
Definition: Key.h:72
A base class for image defects.
bool operator!=(Key const &other) const
Equality comparison.
Definition: Key.h:75
Key< U > key
Definition: Schema.cc:280
Base class for all records.
Definition: BaseRecord.h:31
A class used as a handle to a particular field in a table.
Definition: fwd.h:45
Key()
Default construct a field.
Definition: Key.h:96
std::ostream * os
Definition: Schema.cc:736
static std::string getTypeString()
Return a string description of the field type.
Definition: FieldBase.cc:56
STL class.