LSSTApplications  17.0+124,17.0+14,17.0+73,18.0.0+37,18.0.0+80,18.0.0-4-g68ffd23+4,18.1.0-1-g0001055+12,18.1.0-1-g03d53ef+5,18.1.0-1-g1349e88+55,18.1.0-1-g2505f39+44,18.1.0-1-g5315e5e+4,18.1.0-1-g5e4b7ea+14,18.1.0-1-g7e8fceb+4,18.1.0-1-g85f8cd4+48,18.1.0-1-g8ff0b9f+4,18.1.0-1-ga2c679d+1,18.1.0-1-gd55f500+35,18.1.0-10-gb58edde+2,18.1.0-11-g0997b02+4,18.1.0-13-gfe4edf0b+12,18.1.0-14-g259bd21+21,18.1.0-19-gdb69f3f+2,18.1.0-2-g5f9922c+24,18.1.0-2-gd3b74e5+11,18.1.0-2-gfbf3545+32,18.1.0-26-g728bddb4+5,18.1.0-27-g6ff7ca9+2,18.1.0-3-g52aa583+25,18.1.0-3-g8ea57af+9,18.1.0-3-gb69f684+42,18.1.0-3-gfcaddf3+6,18.1.0-32-gd8786685a,18.1.0-4-gf3f9b77+6,18.1.0-5-g1dd662b+2,18.1.0-5-g6dbcb01+41,18.1.0-6-gae77429+3,18.1.0-7-g9d75d83+9,18.1.0-7-gae09a6d+30,18.1.0-9-gc381ef5+4,w.2019.45
LSSTDataManagementBasePackage
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 
44  Field(std::string const& name, std::string const& doc, std::string const& units = "",
45  FieldBase<T> const& size = FieldBase<T>())
46  : FieldBase<T>(size), _name(name), _doc(doc), _units(units) {}
47 
61  Field(std::string const& name, std::string const& doc, FieldBase<T> const& size)
62  : FieldBase<T>(size), _name(name), _doc(doc), _units() {}
63 
64  Field(Field const&) = default;
65  Field(Field&&) noexcept = default;
66  Field& operator=(Field const&) = default;
67  Field& operator=(Field&&) noexcept = default;
68  ~Field() noexcept = default;
69 
71  std::string const& getName() const noexcept { return _name; }
72 
74  std::string const& getDoc() const noexcept { return _doc; }
75 
77  std::string const& getUnits() const noexcept { return _units; }
78 
80  inline friend std::ostream& operator<<(std::ostream& os, Field<T> const& field) {
81  os << "Field['" << Field<T>::getTypeString() << "'](name=\"" << field.getName() << "\"";
82  if (!field.getDoc().empty()) os << ", doc=\"" << field.getDoc() << "\"";
83  if (!field.getUnits().empty()) os << ", units=\"" << field.getUnits() << "\"";
84  field.stream(os);
85  return os << ")";
86  }
87 
89  Field<T> copyRenamed(std::string const& newName) const {
90  return Field<T>(newName, getDoc(), getUnits(), *this);
91  }
92 
93 private:
94  std::string _name;
95  std::string _doc;
96  std::string _units;
97 };
98 } // namespace table
99 } // namespace afw
100 } // namespace lsst
101 
102 #endif // !AFW_TABLE_Field_h_INCLUDED
Field base class default implementation (used for numeric scalars and lsst::geom::Angle).
Definition: FieldBase.h:43
table::Key< int > field
Definition: ApCorrMap.cc:77
Field(std::string const &name, std::string const &doc, FieldBase< T > const &size)
Construct a new field.
Definition: Field.h:61
std::string const & getDoc() const noexcept
Return the documentation for the field.
Definition: Field.h:74
STL class.
~Field() noexcept=default
Definition: fieldImpl.cc:50
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:89
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:44
std::string const & getName() const noexcept
Return the name of the field.
Definition: Field.h:71
T Element
the type of subfields (the same as the type itself for scalars)
Definition: FieldBase.h:47
FieldBase< T >::Element Element
Type used to store field data in the table (a field may have multiple elements).
Definition: Field.h:26
std::ostream * os
Definition: Schema.cc:746
static std::string getTypeString()
Return a string description of the field type.
Definition: FieldBase.cc:56
STL class.
std::string const & getUnits() const noexcept
Return the units for the field.
Definition: Field.h:77