AGX Dynamics  2.37.3.2
InteractionEntity.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
9 having been advised so by Algoryx Simulation AB for a time limited evaluation,
10 or having purchased a 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 
18 // AUTOMATICALLY GENERATED ENTITY, DO NOT EDIT! //
20 
21 #ifndef GENERATED_AGX_PHYSICS_INTERACTION_H_PLUGIN
22 #define GENERATED_AGX_PHYSICS_INTERACTION_H_PLUGIN
23 
24 #define AGX_ENTITY_WRAPPER 1
25 
26 
27 #ifdef _MSC_VER
28 # pragma warning(push)
29 // warning C4505: 'agxData::VectorAttributeT<T>::print' : unreferenced local function has been removed
30 # pragma warning( disable : 4505 )
31 // warning C4251: 'X' : class 'Y' needs to have dll-interface to be used by clients of class 'Z'
32 # pragma warning( disable : 4251 )
33 // warning C4355: 'this' : used in base member initializer list
34 # pragma warning( disable : 4355 )
35 // marked as __forceinline not inlined
36 # pragma warning( disable: 4714 )
37 #endif
38 
39 #include <agxData/EntityModel.h>
40 #include <agxData/EntityStorage.h>
41 #include <agxData/EntityRef.h>
42 #include <agxData/EntityPtr.h>
43 #include <agxData/EntityInstance.h>
44 #include <agx/Integer.h>
45 #include <agx/Real.h>
46 #include <agx/macros.h>
48 namespace agx { class SolveModel; }
49 
50 namespace agx { namespace Physics { class GraphNodePtr; }}
51 
52 namespace agx
53 {
54  namespace Physics
55  {
56 
57  class InteractionModel;
58  class InteractionData;
59  class InteractionPtr;
60  class InteractionInstance;
61  class InteractionSemantics;
62 
63 
65 
70  {
71  public:
73 
74  InteractionModel(const agx::String& name = "Interaction");
75 
77  static InteractionModel* instance();
78 
80  static InteractionPtr createInstance();
81 
83  static agxData::EntityStorage* defaultStorage();
84 
86  virtual void shutdownCleanup() override;
87 
88 
89 
90  /* Attributes */
93 
94  protected:
95  virtual ~InteractionModel();
96  virtual agxData::EntityData* createData(agxData::EntityStorage* storage) override;
97  virtual void configure(agx::TiXmlElement* eEntity) override;
98  virtual void initAttributeAccessors() override;
99  virtual void construct(agxData::EntityPtr instance) override;
100  void construct(agx::Physics::InteractionPtr interaction);
101  };
102 
103 
105  #ifndef AGX_PHYSICS_INTERACTION_DATA_SET_OVERRIDE
106  #define AGX_PHYSICS_INTERACTION_DATA_SET
107  class AGXPHYSICS_EXPORT InteractionData : public agxData::EntityData
108  {
109  public:
110  InteractionInstance operator[] (size_t index);
111 
112  public:
116 
117  public:
118  typedef agx::SolveModel* solveModelType;
119  typedef agx::Physics::GraphNodePtr graphNodeType;
120 
121  public:
122  InteractionData(agxData::EntityStorage* storage);
123  InteractionData();
124 
125  protected:
126  virtual ~InteractionData() {}
127  virtual void setNumElements(agx::Index numElements) override;
128 
129  private:
130  InteractionData& operator= (const InteractionData&) { return *this; }
131 
132  };
133  #endif
135 
136 
138  class AGXPHYSICS_EXPORT InteractionSemantics : protected agxData::EntityPtr
139  {
140  public:
141 
142  // Automatic getters
143  agx::SolveModel* const& getSolveModel() const;
144  agx::Physics::GraphNodePtr const& getGraphNode() const;
145 
146  // Semantics defined by explicit kernels
147 
148  // Automatic setters
149  void setSolveModel(agx::SolveModel* const& value);
150  void setGraphNode(agx::Physics::GraphNodePtr const& value);
151 
152 
153  protected:
154  friend class InteractionPtr;
155  friend class InteractionInstance;
156  InteractionSemantics();
157  };
159 
160 
161 
164  class CALLABLE InteractionPtr : public agxData::EntityPtr
165  {
166  public:
168  typedef InteractionData DataType;
169  typedef InteractionInstance InstanceType;
170 
171  public:
176  AGXPHYSICS_EXPORT InteractionPtr& operator= (const agxData::EntityPtr& ptr);
177  AGXPHYSICS_EXPORT InteractionPtr& operator= (const agxData::EntityInstance& instance);
178  AGXPHYSICS_EXPORT InteractionInstance instance();
179  AGXPHYSICS_EXPORT const InteractionInstance instance() const;
180 
181  AGXPHYSICS_EXPORT InteractionSemantics* operator->();
182  AGXPHYSICS_EXPORT const InteractionSemantics* operator->() const;
183 
184  InteractionData* getData();
185  const InteractionData* getData() const;
186 
187 
189  AGXPHYSICS_EXPORT agx::SolveModel*& solveModel();
191  AGXPHYSICS_EXPORT agx::SolveModel* const& solveModel() const;
192 
196  AGXPHYSICS_EXPORT agx::Physics::GraphNodePtr const& graphNode() const;
197 
198  };
199 
200 
202  class AGXPHYSICS_EXPORT InteractionInstance : public agxData::EntityInstance
203  {
204  public:
205  InteractionInstance();
206  InteractionInstance(InteractionData* data, agx::Index index);
207  InteractionInstance(agxData::EntityStorage *storage, agx::Index index);
208  InteractionInstance(const agxData::EntityInstance& other);
209  InteractionInstance(const agxData::EntityPtr& ptr);
210 
211  InteractionData* getData();
212  const InteractionData* getData() const;
213 
214  public:
216  agx::SolveModel*& solveModel();
218  agx::SolveModel* const& solveModel() const;
219 
221  agx::Physics::GraphNodePtr& graphNode();
223  agx::Physics::GraphNodePtr const& graphNode() const;
224 
225  };
227 
228 
229 
232 
233 
234 
236  /* Implementation */
237  //-----------------------------------------------------------------------------------------------------
238  //-----------------------------------------------------------------------------------------------------
239  inline InteractionInstance agx::Physics::InteractionData::operator[] (size_t index) { return InteractionInstance(this, (agx::Index)index); }
240  //-----------------------------------------------------------------------------------------------------
244  {
246  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
248  }
249 
251  {
252  agxAssertN(!instance || instance.isInstanceOf(InteractionModel::instance()),
253  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
255  }
256 
258  {
261  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
263  return *this;
264  }
265 
267  {
269  agxAssertN(!instance || instance.isInstanceOf(InteractionModel::instance()),
270  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
272  return *this;
273  }
274 
275  inline InteractionInstance InteractionPtr::instance() { return agxData::EntityPtr::instance(); }
276  inline const InteractionInstance InteractionPtr::instance() const { return agxData::EntityPtr::instance(); }
277  AGX_FORCE_INLINE InteractionSemantics* InteractionPtr::operator->() { return (InteractionSemantics* )this; }
278  AGX_FORCE_INLINE const InteractionSemantics* InteractionPtr::operator->() const { return (const InteractionSemantics* )this; }
279  AGX_FORCE_INLINE InteractionData* InteractionPtr::getData() { return static_cast<InteractionData* >(agxData::EntityPtr::getData()); }
280  AGX_FORCE_INLINE const InteractionData* InteractionPtr::getData() const { return static_cast<const InteractionData* >(agxData::EntityPtr::getData()); }
281 
282  AGX_FORCE_INLINE agx::SolveModel*& InteractionPtr::solveModel() { verifyIndex(); return getData()->solveModel[calculateIndex()]; }
283  AGX_FORCE_INLINE agx::SolveModel* const& InteractionPtr::solveModel() const { verifyIndex(); return getData()->solveModel[calculateIndex()]; }
284 
285  AGX_FORCE_INLINE agx::Physics::GraphNodePtr& InteractionPtr::graphNode() { verifyIndex(); return getData()->graphNode[calculateIndex()]; }
286  AGX_FORCE_INLINE agx::Physics::GraphNodePtr const& InteractionPtr::graphNode() const { verifyIndex(); return getData()->graphNode[calculateIndex()]; }
287 
288  //-----------------------------------------------------------------------------------------------------
289  AGX_FORCE_INLINE InteractionInstance::InteractionInstance() {}
290  AGX_FORCE_INLINE InteractionInstance::InteractionInstance(InteractionData* data, agx::Index index) : agxData::EntityInstance(data, index) {}
291  AGX_FORCE_INLINE InteractionInstance::InteractionInstance(agxData::EntityStorage* storage, agx::Index index) : agxData::EntityInstance(storage, index) {}
292  AGX_FORCE_INLINE InteractionInstance::InteractionInstance(const agxData::EntityInstance& other) : agxData::EntityInstance(other)
293  {
295  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
297  }
298 
299  AGX_FORCE_INLINE InteractionInstance::InteractionInstance(const agxData::EntityPtr& ptr) : agxData::EntityInstance(ptr)
300  {
302  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
304  }
305 
306 
307  AGX_FORCE_INLINE InteractionData* InteractionInstance::getData() { return static_cast<InteractionData* >(agxData::EntityInstance::getData()); }
308  AGX_FORCE_INLINE const InteractionData* InteractionInstance::getData() const { return static_cast<const InteractionData* >(agxData::EntityInstance::getData()); }
309 
310  AGX_FORCE_INLINE agx::SolveModel*& InteractionInstance::solveModel() { verifyIndex(); return getData()->solveModel[getIndex()]; }
311  AGX_FORCE_INLINE agx::SolveModel* const& InteractionInstance::solveModel() const { verifyIndex(); return getData()->solveModel[getIndex()]; }
312 
313  AGX_FORCE_INLINE agx::Physics::GraphNodePtr& InteractionInstance::graphNode() { verifyIndex(); return getData()->graphNode[getIndex()]; }
314  AGX_FORCE_INLINE agx::Physics::GraphNodePtr const& InteractionInstance::graphNode() const { verifyIndex(); return getData()->graphNode[getIndex()]; }
315 
316  //-----------------------------------------------------------------------------------------------------
317  AGX_FORCE_INLINE InteractionSemantics::InteractionSemantics() {}
318  //-----------------------------------------------------------------------------------------------------
320  }
321 }
322 
323 AGX_TYPE_BINDING(agx::Physics::InteractionPtr, "Physics.InteractionPtr")
324 AGX_TYPE_BINDING(agx::Physics::InteractionInstance, "Physics.InteractionInstance")
325 
326 #ifdef _MSC_VER
327 # pragma warning(pop)
328 #endif
329 
330 #undef AGX_ENTITY_WRAPPER
331 #undef AGX_ENTITY_NAMESPACE
332 #endif
333 
agxData::EntityData * getData()
agxData::EntityInstance instance()
Definition: EntityPtr.h:269
Data storage for a collection of entity instances of a specified EntityModel.
Definition: EntityStorage.h:72
#define agxAssertN(expr, format,...)
Definition: debug.h:145
agxData::EntityData * getData()
agx::String fullPath() const
#define AGX_TYPE_BINDING(_Type, _Name)
Definition: Type.h:179
AGXCORE_EXPORT Model * getModel(const Path &path, const Path &_namespace=Path())
Definition: Object.h:363
Pointer to a entity instance of type Physics.Interaction.
AGXPHYSICS_EXPORT InteractionPtr & operator=(const agxData::EntityPtr &ptr)
#define AGXPHYSICS_EXPORT
static agxData::PointerAttributeT< agx::SolveModel * > * solveModelAttribute
InteractionData * getData()
Entity instance provides access to a single instance in an EntityStorage.
Accessor to a entity instance stored in a EntityStorage, to allow SOA (structure of arrays) data to b...
Definition: EntityPtr.h:51
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
bool isInstanceOf(agxData::EntityModel *model) const
#define AGX_FORCE_INLINE
Definition: Object.h:59
Type-specific Array used for fast access into the data held by a Buffer.
Definition: agxData.h:30
Abstract description of the data attributes for the Physics.Interaction entity.
AGXPHYSICS_EXPORT agx::SolveModel *& solveModel()
Vector containing &#39;raw&#39; data.
Definition: Vector.h:245
EntityPtr & operator=(const EntityPtr &other)=default
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
static agxData::ScalarAttributeT< agx::Physics::GraphNodePtr > * graphNodeAttribute
Pointer to a entity instance of type Physics.GraphNode.
Contains classes for low level data storage for AGX.
Definition: Container.h:23
UInt32 Index
Definition: Integer.h:52
InteractionInstance InstanceType
An abstract description of a data entity stored using SOA (structure of arrays) pattern in a EntitySt...
Definition: EntityModel.h:63
AGXPHYSICS_EXPORT InteractionSemantics * operator->()
#define CALLABLE
Definition: Object.h:73
bool isInstanceOf(agxData::EntityModel *model) const
AGXPHYSICS_EXPORT InteractionInstance instance()
static InteractionModel * instance()
AGXPHYSICS_EXPORT InteractionPtr()
AGXPHYSICS_EXPORT agx::Physics::GraphNodePtr & graphNode()
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:98
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:97