AGXDynamics  2.35.0.3
SimulationParameter.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGX_SIMULATIONPARAMETER_H
18 #define AGX_SIMULATIONPARAMETER_H
19 
20 #include <agxSDK/agxSDK.h>
21 
22 #include <agx/Referenced.h>
23 #include <agx/Name.h>
24 #include <agxData/Format.h>
25 #include <agxData/Value.h>
26 
27 namespace agxSDK
28 {
29  class Simulation;
30 
34  {
35  public:
36  SimulationParameter(const agx::Name& name);
37 
38  const agx::Name& getName() const;
39  const agx::String& getDescription() const;
40 
41  void setName(const agx::Name& name);
42  void setDescription(const agx::String& description);
43 
44  virtual const agxData::Format *getFormat() const = 0;
45  virtual const agxData::Value *getValue() const = 0;
46  virtual void setValue(agxData::Value *value) = 0;
47  virtual bool hasSetter() const = 0;
48  virtual bool hasGetter() const = 0;
49 
50 
51  agxSDK::Simulation *getSimulation();
52 
53  protected:
54  virtual ~SimulationParameter();
55 
56  friend class Simulation;
57  virtual void addNotification(agxSDK::Simulation *simulation);
58  virtual void removeNotification(agxSDK::Simulation *simulation);
59 
60  private:
61  agxSDK::Simulation *m_simulation;
62  agx::Name m_name;
63  agx::String m_description;
64  };
65 
66  template <typename T>
68  {
69  public:
70  SimulationParameterT(const agx::Name& name, const T& initialValue = T());
71 
72 
73  virtual void set(const T& value);
74  virtual const T& get() const;
75 
76  virtual const agxData::Format *getFormat() const override;
77  virtual const agxData::Value *getValue() const override;
78  virtual void setValue(agxData::Value *value) override;
79  virtual bool hasSetter() const override;
80  virtual bool hasGetter() const override;
81 
82 
83  protected:
84  virtual ~SimulationParameterT();
85 
86  private:
87  agxData::ValueRefT<T> m_value;
88  };
89 
90 
91  /* Implementation */
92  template <typename T>
94  {
95  m_value = new agxData::ValueT<T>(name, initialValue);
96  }
97 
98 
99  template <typename T>
101  {
102 
103  }
104 
105  template <typename T>
107  {
108  return m_value->get();
109  }
110 
111  template <typename T>
112  void SimulationParameterT<T>::set(const T& value)
113  {
114  m_value->set(value);
115  }
116 
117  template <typename T>
119  {
120  return m_value.get();
121  }
122 
123  template <typename T>
125  {
126  set(value->get<T>());
127  }
128 
129  template <typename T>
131  return true;
132  }
133 
134  template <typename T>
136  return true;
137  }
138 
139  template <typename T>
141  {
142  return m_value->getFormat();
143  }
144 
145 }
146 
147 #endif //AGX_SIMULATIONPARAMETER_H
Referenced.h
agxData::Value
Abstract representation of a value.
Definition: Value.h:42
agxSDK::SimulationParameterT
Definition: SimulationParameter.h:67
agxData::getFormat
AGXCORE_EXPORT Format * getFormat(const agx::String &typeFormatName)
agxSDK::SimulationParameter
Definition: SimulationParameter.h:33
agxData::ValueT
Templated value.
Definition: Value.h:230
Format.h
agxSDK::SimulationParameterT::get
virtual const T & get() const
Definition: SimulationParameter.h:106
agxData::Format
A format is an implementation of a agxData::Type.
Definition: Format.h:63
agxSDK::SimulationParameterT::~SimulationParameterT
virtual ~SimulationParameterT()
Definition: SimulationParameter.h:100
Name.h
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agxSDK::SimulationParameterT::getValue
virtual const agxData::Value * getValue() const override
Definition: SimulationParameter.h:118
agxData::Value::get
const T & get() const
Definition: Value.h:325
AGX_DECLARE_VECTOR_TYPES
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
agxSDK::Simulation
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
agxSDK::SimulationParameterT::hasSetter
virtual bool hasSetter() const override
Definition: SimulationParameter.h:130
agxSDK::SimulationParameterT::hasGetter
virtual bool hasGetter() const override
Definition: SimulationParameter.h:135
agxSDK::SimulationParameterT::SimulationParameterT
SimulationParameterT(const agx::Name &name, const T &initialValue=T())
Definition: SimulationParameter.h:93
agx::Name
Representation of a name string.
Definition: Name.h:32
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:113
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
agxSDK::SimulationParameterT::set
virtual void set(const T &value)
Definition: SimulationParameter.h:112
agxData::ValueRefT
Templated value-reference.
Definition: Value.h:256
agx::AgXString< std::string >
agxSDK
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
agxSDK::SimulationParameterT::getFormat
virtual const agxData::Format * getFormat() const override
Definition: SimulationParameter.h:140
agxSDK::SimulationParameterT::setValue
virtual void setValue(agxData::Value *value) override
Definition: SimulationParameter.h:124
Value.h
agxSDK.h