lsst.afw  14.0-25-g0e8fc950e+6
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 
99  inline friend std::ostream& operator<<(std::ostream& os, Key<T> const& key) {
100  return os << "Key<" << Key<T>::getTypeString() << ">(offset=" << key.getOffset()
101  << ", nElements=" << key.getElementCount() << ")";
102  }
103 
104 private:
105  friend class detail::Access;
106  friend class BaseRecord;
107 
108  explicit Key(int offset, FieldBase<T> const& fb = FieldBase<T>()) : FieldBase<T>(fb), _offset(offset) {}
109 
110  int _offset;
111 };
112 }
113 }
114 } // namespace lsst::afw::table
115 
116 #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
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
Base class for all records.
Definition: BaseRecord.h:29
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
STL class.
static std::string getTypeString()
Return a string description of the field type.