LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
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< 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
Field base class default implementation (used for numeric scalars and Angle).
Definition: FieldBase.h:48
std::string _name
Definition: Field.h:119
table::Key< std::string > name
Definition: ApCorrMap.cc:71
std::string const & getName() const
Return the name of the field.
Definition: Field.h:93
Field(std::string const &name, std::string const &doc, FieldBase< T > const &size)
Construct a new field.
Definition: Field.h:69
std::string const & getDoc() const
Return the documentation for the field.
Definition: Field.h:96
A description of a field in a table.
Definition: Field.h:22
std::string _doc
Definition: Field.h:120
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
T Element
the type of subfields (the same as the type itself for scalars)
Definition: FieldBase.h:53
std::string _units
Definition: Field.h:121
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 & getUnits() const
Return the units for the field.
Definition: Field.h:99
table::Key< int > field
Definition: ApCorrMap.cc:72
static std::string getTypeString()
Return a string description of the field type.