LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
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.