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 <cstdint>
14 #include <string>
15 #include <typeinfo>
16 #include <vector>
17 
19 
20 namespace dynamicgraph {
21 namespace command {
22 class Value;
23 typedef std::vector<Value> Values;
24 
25 class DYNAMIC_GRAPH_DLLAPI EitherType {
26  public:
27  EitherType(const Value &value);
28  ~EitherType();
29  operator bool() const;
30  operator std::uint32_t() const;
31  operator std::uint64_t() const;
32  operator std::int32_t() const;
33  operator std::int64_t() const;
34  operator float() const;
35  operator double() const;
36  operator std::string() const;
37  operator Vector() const;
38  operator Eigen::MatrixXd() const;
39  operator Eigen::Matrix4d() const;
40  operator Values() const;
41 
42  private:
43  const Value *value_;
44 };
45 
51 class DYNAMIC_GRAPH_DLLAPI Value {
52  public:
53  enum Type {
58  INT,
67  NB_TYPES
68  };
69  ~Value();
70  void deleteValue();
71  explicit Value(const bool &value);
72  explicit Value(const std::uint32_t &value);
73  explicit Value(const std::uint64_t &value);
74  explicit Value(const std::int32_t &value);
75  explicit Value(const std::int64_t &value);
76  explicit Value(const float &value);
77  explicit Value(const double &value);
78  explicit Value(const std::string &value);
79  explicit Value(const Vector &value);
80  explicit Value(const Eigen::MatrixXd &value);
81  explicit Value(const Eigen::Matrix4d &value);
82  explicit Value(const Values &value);
84  Value(const Value &value);
85  // Construct an empty value (None)
86  explicit Value();
87  // operator assignement
88  Value operator=(const Value &value);
89  // Equality operator
90  bool operator==(const Value &other) const;
92  Type type() const;
93 
105  const EitherType value() const;
107  static std::string typeName(Type type);
108 
110  DYNAMIC_GRAPH_DLLAPI friend std::ostream &operator<<(std::ostream &os,
111  const Value &value);
112 
113  public:
114  friend class EitherType;
115  bool boolValue() const;
116  std::uint32_t unsignedValue() const;
117  std::uint64_t unsignedlongintValue() const;
118  std::int32_t intValue() const;
119  std::int64_t longintValue() const;
120  float floatValue() const;
121  double doubleValue() const;
122  std::string stringValue() const;
123  Vector vectorValue() const;
124  Eigen::MatrixXd matrixXdValue() const;
125  Eigen::Matrix4d matrix4dValue() const;
126  Values valuesValue() const;
127  const Values &constValuesValue() const;
129  const void *const value_;
130 };
131 
132 /* ---- HELPER ---------------------------------------------------------- */
133 // Note: to ensure the WIN32 compatibility, it is necessary to export
134 // the template specialization. Also, it is forbidden to do the template
135 // specialization declaration in the header file, for the same reason.
136 template <typename T>
137 struct DYNAMIC_GRAPH_DLLAPI ValueHelper {
138  static const Value::Type TypeID;
139 };
140 } // namespace command
141 } // namespace dynamicgraph
142 
143 #endif // DYNAMIC_GRAPH_VALUE_H
linear-algebra.h
dynamicgraph::command::Value::type_
Type type_
Definition: value.h:128
dynamic-graph-api.h
dynamicgraph::command::ValueHelper
Definition: value.h:137
dynamicgraph::command::Value::MATRIX4D
@ MATRIX4D
Definition: value.h:65
dynamicgraph
dynamicgraph::command::Values
std::vector< Value > Values
Definition: value.h:22
dynamicgraph::command::Value::INT
@ INT
Definition: value.h:58
dynamicgraph::command::EitherType
Definition: value.h:25
dynamicgraph::command::operator<<
std::ostream & operator<<(std::ostream &os, const Value &value)
Definition: src/command/value.cpp:313
dynamicgraph::command::ValueHelper::TypeID
static const Value::Type TypeID
Definition: value.h:138
dynamicgraph::command::Value::VALUES
@ VALUES
Definition: value.h:66
dynamicgraph::command::Value::value_
const void *const value_
Definition: value.h:129
dynamicgraph::command::Value::STRING
@ STRING
Definition: value.h:62
dynamicgraph::command::Value::UNSIGNED
@ UNSIGNED
Definition: value.h:56
dynamicgraph::command::Value::NONE
@ NONE
Definition: value.h:54
dynamicgraph::command::Value::BOOL
@ BOOL
Definition: value.h:55
dynamicgraph::command::Value::DOUBLE
@ DOUBLE
Definition: value.h:61
dynamicgraph::Vector
Eigen::VectorXd Vector
Definition: linear-algebra.h:14
dynamicgraph::command::Value::VECTOR
@ VECTOR
Definition: value.h:63
dynamicgraph::command::EitherType::value_
const Value * value_
Definition: value.h:43
dynamicgraph::command::Value::MATRIX
@ MATRIX
Definition: value.h:64
dynamicgraph::command::Value::LONGINT
@ LONGINT
Definition: value.h:59
dynamicgraph::command::Value::Type
Type
Definition: value.h:53
dynamicgraph::command::Value::FLOAT
@ FLOAT
Definition: value.h:60
dynamicgraph::command::Value::UNSIGNEDLONGINT
@ UNSIGNEDLONGINT
Definition: value.h:57
dynamicgraph::command::Value
This class implements a variant design pattern to handle basic types in Command.
Definition: value.h:51


dynamic-graph
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Fri Aug 2 2024 08:36:38