value.h
Go to the documentation of this file.
1 //
2 // Copyright 2010 CNRS
3 //
4 // Author: Florent Lamiraux
5 //
6 
7 #ifndef DYNAMIC_GRAPH_VALUE_H
8 #define DYNAMIC_GRAPH_VALUE_H
9 
11 
12 #include <cassert>
13 #include <string>
14 #include <typeinfo>
15 #include <vector>
16 
18 
19 namespace dynamicgraph {
20 namespace command {
21 class Value;
22 typedef std::vector<Value> Values;
23 
24 class DYNAMIC_GRAPH_DLLAPI EitherType {
25  public:
26  EitherType(const Value &value);
27  ~EitherType();
28  operator bool() const;
29  operator unsigned() const;
30  operator unsigned long int() const;
31  operator int() const;
32  operator long int() const;
33  operator float() const;
34  operator double() const;
35  operator std::string() const;
36  operator Vector() const;
37  operator Eigen::MatrixXd() const;
38  operator Eigen::Matrix4d() const;
39  operator Values() const;
40 
41  private:
42  const Value *value_;
43 };
44 
50 class DYNAMIC_GRAPH_DLLAPI Value {
51  public:
52  enum Type {
57  INT,
66  NB_TYPES
67  };
68  ~Value();
69  void deleteValue();
70  explicit Value(const bool &value);
71  explicit Value(const unsigned &value);
72  explicit Value(const unsigned long int &value);
73  explicit Value(const int &value);
74  explicit Value(const long int &value);
75  explicit Value(const float &value);
76  explicit Value(const double &value);
77  explicit Value(const std::string &value);
78  explicit Value(const Vector &value);
79  explicit Value(const Eigen::MatrixXd &value);
80  explicit Value(const Eigen::Matrix4d &value);
81  explicit Value(const Values &value);
83  Value(const Value &value);
84  // Construct an empty value (None)
85  explicit Value();
86  // operator assignement
87  Value operator=(const Value &value);
88  // Equality operator
89  bool operator==(const Value &other) const;
91  Type type() const;
92 
104  const EitherType value() const;
106  static std::string typeName(Type type);
107 
109  DYNAMIC_GRAPH_DLLAPI friend std::ostream &operator<<(std::ostream &os,
110  const Value &value);
111 
112  public:
113  friend class EitherType;
114  bool boolValue() const;
115  unsigned unsignedValue() const;
116  unsigned long int unsignedlongintValue() const;
117  int intValue() const;
118  long int longintValue() const;
119  float floatValue() const;
120  double doubleValue() const;
121  std::string stringValue() const;
122  Vector vectorValue() const;
123  Eigen::MatrixXd matrixXdValue() const;
124  Eigen::Matrix4d matrix4dValue() const;
125  Values valuesValue() const;
126  const Values &constValuesValue() const;
128  const void *const value_;
129 };
130 
131 /* ---- HELPER ---------------------------------------------------------- */
132 // Note: to ensure the WIN32 compatibility, it is necessary to export
133 // the template specialization. Also, it is forbidden to do the template
134 // specialization declaration in the header file, for the same reason.
135 template <typename T>
136 struct DYNAMIC_GRAPH_DLLAPI ValueHelper {
137  static const Value::Type TypeID;
138 };
139 } // namespace command
140 } // namespace dynamicgraph
141 
142 #endif // DYNAMIC_GRAPH_VALUE_H
Eigen::VectorXd Vector
const void *const value_
Definition: value.h:128
This class implements a variant design pattern to handle basic types in Command.
Definition: value.h:50
static const Value::Type TypeID
Definition: value.h:137
std::vector< Value > Values
Definition: value.h:21
std::ostream & operator<<(std::ostream &os, const Value &value)


dynamic-graph
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Sun Jun 25 2023 02:06:03