Rumba C++ SDK
Value.h
Go to the documentation of this file.
1 /*
2 
3  *
4  ***
5  *****
6  ********************* Mercenaries Engineering SARL
7  ***************** Copyright (C) 2018
8  *************
9  ********* http://www.mercenaries-engineering.com
10  ***********
11  **** ****
12  ** **
13 
14 */
15 #pragma once
16 
17 #include "Impl.h"
18 #include "StringView.h"
19 #include "Macros.h"
20 
21 MAQUINA_IGNORE_WARNINGS_BEGIN
22 #include <ImathBox.h>
23 #include <ImathColor.h>
24 #include <ImathMatrix.h>
25 #include <ImathQuat.h>
26 MAQUINA_IGNORE_WARNINGS_END
27 
28  namespace maquina
29  {
30  class UserData;
31  class NodeDelegate;
32 
35  {
36  public:
37  Value();
38 
41 
44  Value(bool);
46  Value(int);
48  Value(float);
50  Value(double);
52  Value(const char *string);
54  Value(const wchar_t *string);
56  Value(const std::string &string);
58  Value(const std::wstring &string);
60  Value(const Imath::V2f &);
62  Value(const Imath::V3f &);
64  Value(const Imath::V4f &);
66  Value(const Imath::V2d &);
68  Value(const Imath::V3d &);
70  Value(const Imath::V4d &);
72  Value(const Imath::V2i &);
74  Value(const Imath::V3i &);
76  Value(const Imath::V4i &);
78  Value(const Imath::Color4f &);
80  Value(const Imath::M44f &);
82  Value(const Imath::M44d &);
84  Value(const Imath::Box3f &);
86  Value(const Imath::Quatf &);
88  Value(const Imath::Quatd &);
90  Value(const std::shared_ptr<const UserData>& user_data);
91 
93 
95 
96  Value duplicate() const;
97 
99 
100  bool as_bool() const;
101 
103 
104  int as_int() const;
105 
107 
108  float as_float() const;
109 
111 
112  double as_double() const;
113 
115 
116  const std::string& as_string() const;
117 
119 
120  std::wstring as_wstring() const;
121 
123 
124  Imath::V2f as_V2f() const;
125 
127 
128  Imath::V3f as_V3f() const;
129 
131 
132  Imath::V4f as_V4f() const;
133 
135 
136  const Imath::V2d& as_V2d() const;
137 
139 
140  const Imath::V3d& as_V3d() const;
141 
143 
144  const Imath::V4d& as_V4d() const;
145 
147 
148  const Imath::V2i& as_V2i() const;
149 
151 
152  const Imath::V3i& as_V3i() const;
153 
155 
156  const Imath::V4i& as_V4i() const;
157 
159 
160  Imath::M44f as_M44f() const;
161 
163 
164  const Imath::M44d &as_M44d() const;
165 
167 
168  const Imath::Box3f& as_Box3f() const;
169 
171 
172  const Imath::Color4f& as_Color4f() const;
173 
175 
176  Imath::Quatf as_Quatf() const;
177 
179 
180  const Imath::Quatd& as_Quatd() const;
181 
183 
184  std::shared_ptr<const UserData> as_user_data() const;
185 
186 
188 
190  StringView type_name() const;
191 
193  bool has_node_delegate() const;
194 
200  std::shared_ptr< NodeDelegate> node_delegate(
201  const std::shared_ptr<NodeDelegate>& parent,
202  const StringView& name) const;
203 
205  bool operator==(const Value& o) const;
206  bool operator!=(const Value& o) const;
207 
209  bool is_instance( const char* value_type_name ) const;
210 
219  bool is_interpolable() const;
220 
236  Value lerp(const Value& other, double weight) const;
237 
239  static bool validate_type_name(const char* type_name);
240 
242  static Value get_default_value(const char* type_name);
243 
245  static const Value default_value;
246 
248  std::shared_ptr<Impl> _impl;
249 
251  Value(const std::shared_ptr<Impl> &impl) { _impl=impl; }
252  };
253  }
254 
255 // A hash implementation which uses the implementation pointer.
256 // Consistent with the way equality works.
257 // Allows using Value as a map key.
258 template<>
259 struct std::hash<maquina::Value>
260 {
261  std::size_t operator()(maquina::Value const &v) const noexcept
262  {
263  return std::hash<maquina::Impl *>{}(v._impl.get());
264  }
265 };
Definition: ImathBox.h:71
Definition: ImathFrame.h:42
Definition: ImathColor.h:120
std::size_t operator()(maquina::Value const &v) const noexcept
Definition: Value.h:261
Definition: ImathFrame.h:43
Buffer< T > duplicate(const BufferConst< T > &a)
Definition: Buffer.h:169
MAQUINA_EXPORT Imath::M44f lerp(const Imath::M44f &a, const Imath::M44f &b, float w)
Interplate two matrices.
Definition: ImathVec.h:63
This version of the SDK is unstable, i-e, it may change with no warning.
Definition: AddCurveAction.h:20
static const Value default_value
The default value.
Definition: Value.h:245
Definition: ImathQuat.h:71
#define MAQUINA_EXPORT
Definition: Export.h:31
bool operator!=(const C *str, const StringViewBase< C, STDS > &sv) noexcept
Definition: StringView.h:306
Definition: ImathVec.h:61
bool operator==(const C *str, const StringViewBase< C, STDS > &sv) noexcept
Definition: StringView.h:274
Base class of all Rumba values.
Definition: Value.h:34