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
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 { namespace afw { namespace table {
10 
21 template <typename T>
22 struct Field : public FieldBase<T> {
23 
25  typedef typename FieldBase<T>::Element Element;
26 
47  std::string const & name,
48  std::string const & doc,
49  std::string const & units = "",
50  FieldBase<T> const & size = FieldBase<T>()
51  ) : FieldBase<T>(size), _name(name), _doc(doc), _units(units) {}
52 
70  std::string const & name,
71  std::string const & doc,
72  FieldBase<T> const & size
73  ) : FieldBase<T>(size), _name(name), _doc(doc), _units() {}
74 
75 #ifdef SWIG
76  // SWIG doesn't understand implicit conversions from int to FieldBase, even with %implicitconv.
77  // We don't need to define these, because when SWIG calls them in its implementation, the
78  // implicit conversion *will* work.
79  Field(
80  std::string const & name,
81  std::string const & doc,
82  std::string const & units,
83  int size
84  );
85  Field(
86  std::string const & name,
87  std::string const & doc,
88  int size
89  );
90 #endif
91 
93  std::string const & getName() const { return _name; }
94 
96  std::string const & getDoc() const { return _doc; }
97 
99  std::string const & getUnits() const { return _units; }
100 
102  inline friend std::ostream & operator<<(std::ostream & os, Field<T> const & field) {
103  os << "Field['" << Field<T>::getTypeString()
104  << "'](name=\"" << field.getName() << "\"";
105  if (!field.getDoc().empty())
106  os << ", doc=\"" << field.getDoc() << "\"";
107  if (!field.getUnits().empty())
108  os << ", units=\"" << field.getUnits() << "\"";
109  field.stream(os);
110  return os << ")";
111  }
112 
114  Field<T> copyRenamed(std::string const & newName) const {
115  return Field<T>(newName, getDoc(), getUnits(), *this);
116  }
117 
118 private:
119  std::string _name;
120  std::string _doc;
121  std::string _units;
122 };
123 
124 }}} // namespace lsst::afw::table
125 
126 #endif // !AFW_TABLE_Field_h_INCLUDED
Field base class default implementation (used for numeric scalars and Angle).
Definition: FieldBase.h:48
table::Key< std::string > name
Definition: ApCorrMap.cc:71
std::string _doc
Definition: Field.h:120
static std::string getTypeString()
Return a string description of the field type.
std::string _name
Definition: Field.h:119
Field(std::string const &name, std::string const &doc, FieldBase< T > const &size)
Construct a new field.
Definition: Field.h:69
A description of a field in a table.
Definition: Field.h:22
std::string _units
Definition: Field.h:121
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:46
std::string const & getName() const
Return the name of the field.
Definition: Field.h:93
FieldBase< T >::Element Element
Type used to store field data in the table (a field may have multiple elements).
Definition: Field.h:25
std::string const & getDoc() const
Return the documentation for the field.
Definition: Field.h:96
T Element
the type of subfields (the same as the type itself for scalars)
Definition: FieldBase.h:53
std::string const & getUnits() const
Return the units for the field.
Definition: Field.h:99
table::Key< int > field
Definition: ApCorrMap.cc:72
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:114