Bayeux  3.4.1
Core Foundation library for SuperNEMO
data_description.h
Go to the documentation of this file.
1 //
4 // Copyright (c) 2015 by François Mauger <mauger@lpccaen.in2p3.fr>
5 //
6 // This file is part of Datatools.
7 //
8 // Datatools is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 //
13 // Datatools is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with Datatools. If not, see <http://www.gnu.org/licenses/>.
20 
21 #ifndef DATATOOLS_INTROSPECTION_DATA_DESCRIPTION_H
22 #define DATATOOLS_INTROSPECTION_DATA_DESCRIPTION_H
23 
24 // Third party:
25 // - Boost:
26 #include <boost/optional.hpp>
27 // - Bayeux/datatools:
28 #include <datatools/properties.h>
29 
30 // This project:
34 
35 namespace datatools {
36 
37  namespace introspection {
38 
42  {
43  public:
44 
47 
50 
52  bool has_type() const;
53 
55  data_type get_type() const;
56 
58  void set_type(data_type);
59 
61  const std::type_info & native_type() const;
62 
64  bool has_layout() const;
65 
67  data_layout get_layout() const;
68 
70  std::string get_layout_label() const;
71 
73  void set_layout(data_layout);
74 
76  bool has_vector_fixed_size() const;
77 
79  std::size_t get_vector_fixed_size() const;
80 
82  void set_vector_fixed_size(std::size_t);
83 
86 
88  bool has_unit_info() const;
89 
91  bool has_unit_support() const;
92 
94  const unit_info & get_unit_info() const;
95 
97  void set_unit_info(const unit_info & ui_);
98 
100  void reset_unit_info();
101 
103  bool is_dimensionless() const;
104 
106  bool has_implicit_unit() const;
107 
109  const std::string & get_implicit_unit_symbol() const;
110 
112  bool has_explicit_unit_dimension() const;
113 
115  const std::string & get_explicit_unit_dimension_label() const;
116 
118  bool has_preferred_unit() const;
119 
121  const std::string & get_preferred_unit_symbol() const;
122 
124  std::string get_unit_dimension_label() const;
125 
127  bool has_type_id() const;
128 
130  const std::string & get_type_id() const;
131 
133  void set_type_id(const std::string &);
134 
136  void reset_type_id();
137 
139  bool is_valid() const;
140 
142  void initialize();
143 
145 
159  void initialize(const datatools::properties &);
160 
162  void reset();
163 
165  enum dd_xc_flags {
173  | DD_XC_TYPE
174  | DD_XC_LAYOUT
177  | DD_XC_TYPE_ID),
179  };
180 
183  uint32_t flags_ = DD_XC_DEFAULT,
184  const std::string & prefix_ = "") const;
185 
187  virtual void tree_dump(std::ostream & out_ = std::clog,
188  const std::string & title_ = "",
189  const std::string & indent_ = "",
190  bool inherit_ = false) const;
191 
193  void make_scalar(data_type, const std::string & info_ = "", const std::string & info2_ = "");
194 
196  void make_fixed_size_vector(data_type, std::size_t size_, const std::string & info_ = "", const std::string & info2_ = "");
197 
199  void make_free_size_vector(data_type, const std::string & info_ = "", const std::string & info2_ = "");
200 
201  private:
202 
204  void _set_defaults();
205 
207  void _make_unit(const std::string & utoken_ = "", const std::string & utoken2_ = "");
208 
209  private:
210 
211  data_type _type_;
212  data_layout _layout_;
213  boost::optional<std::size_t> _vector_fixed_size_;
214  boost::optional<unit_info> _unit_info_;
215  boost::optional<std::string> _type_id_;
216  // type restriction
217 
218  };
219 
220  } // namespace introspection
221 
222 } // namespace datatools
223 
224 #endif // DATATOOLS_INTROSPECTION_DATA_DESCRIPTION_H
225 
226 // Local Variables: --
227 // mode: c++ --
228 // c-file-style: "gnu" --
229 // tab-width: 2 --
230 // End: --
bool has_unit_support() const
Check if data description has unit support.
std::string get_unit_dimension_label() const
Return the unit dimension label.
Data description.
Definition: data_description.h:40
std::size_t get_vector_fixed_size() const
Return the vector fixed size.
const std::string & get_type_id() const
Return the type identifier (for enumeration and class)
const std::string & get_explicit_unit_dimension_label() const
Return the real data explicit unit dimension label ("length"/"time"/"mass"...)
data_layout
Layout (scalar/vector) of the data.
Definition: data_layout.h:43
bool has_unit_info() const
Check if unit info is defined.
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
static const uint32_t bit01
Definition: bit_mask.h:28
bool has_type_id() const
Check if the data has a type identifier (for enumeration and class)
static const uint32_t bit03
Definition: bit_mask.h:30
const std::string & get_implicit_unit_symbol() const
Return the real data implicit unit symbol.
const std::string & get_preferred_unit_symbol() const
Return the (real) data preferred unit (ex: "volt", "ns", "mA"...)
bool has_vector_fixed_size() const
Check if vector fixed size is defined.
static const uint32_t bit04
Definition: bit_mask.h:31
bool has_preferred_unit() const
Check if the (real) data has a preferred unit (ex: "volt", "ns", "mA"...)
void make_free_size_vector(data_type, const std::string &info_="", const std::string &info2_="")
Build a vector data with free size.
void make_fixed_size_vector(data_type, std::size_t size_, const std::string &info_="", const std::string &info2_="")
Build a vector data with fixed size.
bool has_implicit_unit() const
Check if the (real) data is stored using an implicit unit (ex: "volt", "ns", "mA"....
bool has_explicit_unit_dimension() const
Check if the (real) data is stored using an explicit unit of known dimension (ex: "length"/"time"/"ma...
void export_to_config(datatools::properties &config_, uint32_t flags_=DD_XC_DEFAULT, const std::string &prefix_="") const
Export to a container of properties.
bool is_dimensionless() const
Check if real data is dimensionless.
void set_unit_info(const unit_info &ui_)
Set the unit information.
std::string get_layout_label() const
Return the labale associated to the data layout.
const std::type_info & native_type() const
Return the native type.
static const uint32_t bit02
Definition: bit_mask.h:29
static const uint32_t bit05
Definition: bit_mask.h:32
void reset_vector_fixed_size()
Reset the vector fixed size.
void set_type(data_type)
Set the data type.
void reset_type_id()
Reset the type identifier (for enumeration and class)
data_layout get_layout() const
Return the data layout.
data_type
Supported data types.
Definition: data_type.h:41
void set_layout(data_layout)
Set the data layout.
const unit_info & get_unit_info() const
Return the unit information.
Data type information.
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
Unit support utilities.
void set_vector_fixed_size(std::size_t)
Set the vector fixed size.
void make_scalar(data_type, const std::string &info_="", const std::string &info2_="")
Build a scalar data.
data_type get_type() const
Return the data type.
static const uint32_t bit00
Definition: bit_mask.h:27
void reset_unit_info()
Reset the unit info.
Data layout information.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
bool is_valid() const
Check validity.
bool has_type() const
Check if data type is defined.
dd_xc_flags
Flags for export to a container of properties.
Definition: data_description.h:165
bool has_layout() const
Check if data layout is defined.
void set_type_id(const std::string &)
Set the type identifier (for enumeration and class)
A dictionary of arbitrary properties.
Definition: properties.h:125
Unit information associated to a parameter.
Definition: unit_support.h:66