LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
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 { namespace afw { namespace table {
10 
11 namespace detail {
12 
13 class Access;
14 
15 } // namespace detail
16 
49 template <typename T>
50 class Key : public KeyBase<T>, public FieldBase<T> {
51 public:
52 
54 
63  template <typename OtherT> bool operator==(Key<OtherT> const & other) const { return false; }
64  template <typename OtherT> bool operator!=(Key<OtherT> const & other) const { return true; }
65 
66  bool operator==(Key const & other) const {
67  return _offset == other._offset && this->getElementCount() == other.getElementCount();
68  }
69  bool operator!=(Key const & other) const { return !this->operator==(other); }
71 
73  int getOffset() const { return _offset; }
74 
83  bool isValid() const { return _offset >= 0; }
84 
90  Key() : FieldBase<T>(FieldBase<T>::makeDefault()), _offset(-1) {}
91 
93  inline friend std::ostream & operator<<(std::ostream & os, Key<T> const & key) {
94  return os << "Key<" << Key<T>::getTypeString() << ">(offset=" << key.getOffset()
95  << ", nElements=" << key.getElementCount() << ")";
96  }
97 
98 private:
99 
100  friend class detail::Access;
101  friend class BaseRecord;
102 
103  explicit Key(int offset, FieldBase<T> const & fb = FieldBase<T>())
104  : FieldBase<T>(fb), _offset(offset) {}
105 
106  int _offset;
107 };
108 
109 }}} // namespace lsst::afw::table
110 
111 #endif // !AFW_TABLE_Key_h_INCLUDED
Key(int offset, FieldBase< T > const &fb=FieldBase< T >())
Definition: Key.h:103
Field base class default implementation (used for numeric scalars and Angle).
Definition: FieldBase.h:48
bool operator==(Key< OtherT > const &other) const
Equality comparison.
Definition: Key.h:63
bool operator!=(Key< OtherT > const &other) const
Equality comparison.
Definition: Key.h:64
bool operator==(Key const &other) const
Equality comparison.
Definition: Key.h:66
bool isValid() const
Return true if the key was initialized to valid offset.
Definition: Key.h:83
static std::string getTypeString()
Return a string description of the field type.
bool operator!=(Key const &other) const
Equality comparison.
Definition: Key.h:69
int getElementCount() const
Return the number of subfield elements (always one for scalars).
Definition: FieldBase.h:56
Base class for all records.
Definition: BaseRecord.h:27
A class used as a handle to a particular field in a table.
Definition: fwd.h:44
static FieldBase makeDefault()
Needed to allow Keys to be default-constructed.
Definition: FieldBase.h:77
Key()
Default construct a field.
Definition: Key.h:90
int getOffset() const
Return the offset (in bytes) of this field within a record.
Definition: Key.h:73