lsst.afw  14.0-60-ga423a1d65+1
Field.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 #ifndef AFW_TABLE_Field_h_INCLUDED
3 #define AFW_TABLE_Field_h_INCLUDED
4 
5 #include <iostream>
6 
8 
9 namespace lsst {
10 namespace afw {
11 namespace table {
12 
23 template <typename T>
24 struct Field : public FieldBase<T> {
26  typedef typename FieldBase<T>::Element Element;
27 
47  Field(std::string const& name, std::string const& doc, std::string const& units = "",
48  FieldBase<T> const& size = FieldBase<T>())
49  : FieldBase<T>(size), _name(name), _doc(doc), _units(units) {}
50 
67  Field(std::string const& name, std::string const& doc, FieldBase<T> const& size)
68  : FieldBase<T>(size), _name(name), _doc(doc), _units() {}
69 
70  Field(Field const &) = default;
71  Field(Field &&) = default;
72  Field & operator=(Field const &) = default;
73  Field & operator=(Field &&) = default;
74  ~Field() = default;
75 
77  std::string const& getName() const { return _name; }
78 
80  std::string const& getDoc() const { return _doc; }
81 
83  std::string const& getUnits() const { return _units; }
84 
86  inline friend std::ostream& operator<<(std::ostream& os, Field<T> const& field) {
87  os << "Field['" << Field<T>::getTypeString() << "'](name=\"" << field.getName() << "\"";
88  if (!field.getDoc().empty()) os << ", doc=\"" << field.getDoc() << "\"";
89  if (!field.getUnits().empty()) os << ", units=\"" << field.getUnits() << "\"";
90  field.stream(os);
91  return os << ")";
92  }
93 
95  Field<T> copyRenamed(std::string const& newName) const {
96  return Field<T>(newName, getDoc(), getUnits(), *this);
97  }
98 
99 private:
100  std::string _name;
101  std::string _doc;
102  std::string _units;
103 };
104 }
105 }
106 } // namespace lsst::afw::table
107 
108 #endif // !AFW_TABLE_Field_h_INCLUDED
Field base class default implementation (used for numeric scalars and Angle).
Definition: FieldBase.h:44
table::Key< std::string > name
Definition: ApCorrMap.cc:71
std::string const & getName() const
Return the name of the field.
Definition: Field.h:77
Field(std::string const &name, std::string const &doc, FieldBase< T > const &size)
Construct a new field.
Definition: Field.h:67
STL class.
A base class for image defects.
Field< T > copyRenamed(std::string const &newName) const
Return a new Field with a new name and other properties the same as this.
Definition: Field.h:95
A description of a field in a table.
Definition: Field.h:24
Field & operator=(Field const &)=default
Field(std::string const &name, std::string const &doc, std::string const &units="", FieldBase< T > const &size=FieldBase< T >())
Construct a new field.
Definition: Field.h:47
T Element
the type of subfields (the same as the type itself for scalars)
Definition: FieldBase.h:48
std::string const & getDoc() const
Return the documentation for the field.
Definition: Field.h:80
std::string const & getUnits() const
Return the units for the field.
Definition: Field.h:83
FieldBase< T >::Element Element
Type used to store field data in the table (a field may have multiple elements).
Definition: Field.h:26
STL class.
table::Key< int > field
Definition: ApCorrMap.cc:72
static std::string getTypeString()
Return a string description of the field type.