AGX Dynamics  2.37.3.2
SimulationParameter.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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
virtual void set(const T &value)
Abstract representation of a value.
Definition: Value.h:48
AGXCORE_EXPORT Format * getFormat(const agx::String &typeFormatName)
SimulationParameterT(const agx::Name &name, const T &initialValue=T())
#define AGXPHYSICS_EXPORT
A format is an implementation of a agxData::Type.
Definition: Format.h:63
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
virtual const agxData::Format * getFormat() const override
virtual const T & get() const
Representation of a name string.
Definition: Name.h:32
Templated value-reference.
Definition: Value.h:262
virtual bool hasGetter() const override
Base class providing referencing counted objects.
Definition: Referenced.h:119
virtual bool hasSetter() const override
virtual void setValue(agxData::Value *value) override
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
const T & get() const
Definition: Value.h:331
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
virtual const agxData::Value * getValue() const override
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
Templated value.
Definition: Value.h:236