Go to the documentation of this file. 1 #ifndef CNOID_MANIPULATOR_PLUGIN_MPR_VARIBLE_H
2 #define CNOID_MANIPULATOR_PLUGIN_MPR_VARIBLE_H
4 #include <cnoid/Referenced>
5 #include <cnoid/GeneralId>
6 #include <cnoid/Signal>
7 #include <cnoid/stdx/variant>
9 #include "exportdecl.h"
13 class MprVariableList;
18 typedef stdx::variant<int, double, bool, std::string>
Value;
19 enum TypeId { Int, Double, Bool, String };
26 static int valueType(
const Value& value) {
return stdx::get_variant_index(value); }
27 static int intValue(
const Value& value) {
return stdx::get<int>(value); }
30 static const std::string&
stringValue(
const Value& value) {
return stdx::get<std::string>(value); }
31 static bool toBool(
const Value& value);
36 int valueType()
const {
return stdx::get_variant_index(value_); }
37 bool changeValueType(TypeId type);
39 bool isInt()
const {
return valueType() == Int; }
40 bool isDouble()
const {
return valueType() == Double; }
41 bool isBool()
const {
return valueType() == Bool; }
42 bool isString()
const {
return valueType() == String; }
44 template<
class T> T
value()
const {
return stdx::get<T>(value_); }
46 int intValue()
const {
return stdx::get<int>(value_); }
47 double doubleValue()
const {
return stdx::get<double>(value_); }
48 bool boolValue()
const {
return stdx::get<bool>(value_); }
49 const std::string&
stringValue()
const {
return stdx::get<std::string>(value_); }
51 bool setValue(
int value);
52 bool setValue(
double value);
53 bool setValue(
bool value);
54 bool setValue(
const std::string& value);
55 bool setValue(
const Value& value);
58 std::string toString()
const;
60 const std::string&
note()
const {
return note_; }
61 void setNote(
const std::string& note) { note_ = note; }
74 void notifyUpdate(
int flags = ValueUpdate);
81 Signal<void(
int flags)> sigUpdated_;
85 template<
class ValueType>
86 bool setScalarValue(ValueType value);
Definition: MprVariable.h:15
SignalProxy< void(int flags)> sigUpdated()
Definition: MprVariable.h:73
Definition: ValueTree.h:253
Definition: GeneralId.h:11
const std::string & note() const
Definition: MprVariable.h:60
Listing * write(Mapping *mapping, const std::string &key, const Eigen::MatrixBase< Derived > &x)
Definition: EigenArchive.h:145
Definition: Referenced.h:276
int valueType() const
Definition: MprVariable.h:36
void setNote(const std::string ¬e)
Definition: MprVariable.h:61
bool read(const Mapping *mapping, const std::string &key, Eigen::MatrixBase< Derived > &x)
Definition: EigenArchive.h:43
Definition: Referenced.h:103
ref_ptr< MprVariable > MprVariablePtr
Definition: MprVariable.h:89
bool isDouble() const
Definition: MprVariable.h:40
stdx::variant< int, double, bool, std::string > Value
Definition: MprVariable.h:18
int intValue() const
Definition: MprVariable.h:46
double doubleValue() const
Definition: MprVariable.h:47
bool isBool() const
Definition: MprVariable.h:41
UpdateFlag
Definition: MprVariable.h:68
const std::string & stringValue() const
Definition: MprVariable.h:49
static const std::string & stringValue(const Value &value)
Definition: MprVariable.h:30
static int intValue(const Value &value)
Definition: MprVariable.h:27
static int valueType(const Value &value)
Definition: MprVariable.h:26
static double doubleValue(const Value &value)
Definition: MprVariable.h:28
Definition: AbstractSceneLoader.h:11
bool isString() const
Definition: MprVariable.h:42
T value() const
Definition: MprVariable.h:44
TypeId
Definition: MprVariable.h:19
Definition: MprVariableList.h:12
Definition: Referenced.h:54
bool isInt() const
Definition: MprVariable.h:39
static bool boolValue(const Value &value)
Definition: MprVariable.h:29
bool toBool() const
Definition: MprVariable.h:57
const GeneralId & id() const
Definition: MprVariable.h:33
Value value() const
Definition: MprVariable.h:45
bool boolValue() const
Definition: MprVariable.h:48