AGX Dynamics  2.35.0.1
InteractionEntity.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
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 
78 
81 
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;
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:
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 
197 
199  // Only used by tolua!
200  #ifdef AGX_GENERATED_TOLUA_WRAPPER
201  inline agx::SolveModel* const& getSolveModel() const { return (*this)->getSolveModel(); }
202  inline agx::Physics::GraphNodePtr const& getGraphNode() const { return (*this)->getGraphNode(); }
203 
204 
205  inline void setSolveModel(agx::SolveModel* const& value) { (*this)->setSolveModel(value); }
206  inline void setGraphNode(agx::Physics::GraphNodePtr const& value) { (*this)->setGraphNode(value); }
207  #endif
209 
210  };
211 
212 
214  class AGXPHYSICS_EXPORT InteractionInstance : public agxData::EntityInstance
215  {
216  public:
217  InteractionInstance();
218  InteractionInstance(InteractionData* data, agx::Index index);
219  InteractionInstance(agxData::EntityStorage *storage, agx::Index index);
220  InteractionInstance(const agxData::EntityInstance& other);
221  InteractionInstance(const agxData::EntityPtr& ptr);
222 
223  InteractionData* getData();
224  const InteractionData* getData() const;
225 
226  public:
228  agx::SolveModel*& solveModel();
230  agx::SolveModel* const& solveModel() const;
231 
233  agx::Physics::GraphNodePtr& graphNode();
235  agx::Physics::GraphNodePtr const& graphNode() const;
236 
237  };
239 
240 
241 
244 
245 
246 
248  /* Implementation */
249  //-----------------------------------------------------------------------------------------------------
250  //-----------------------------------------------------------------------------------------------------
251  inline InteractionInstance agx::Physics::InteractionData::operator[] (size_t index) { return InteractionInstance(this, (agx::Index)index); }
252  //-----------------------------------------------------------------------------------------------------
255  AGX_FORCE_INLINE InteractionPtr::InteractionPtr(const agxData::EntityPtr& ptr) : agxData::EntityPtr(ptr)
256  {
258  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
260  }
261 
262  AGX_FORCE_INLINE InteractionPtr::InteractionPtr(const agxData::EntityInstance& instance) : agxData::EntityPtr(instance)
263  {
264  agxAssertN(!instance || instance.isInstanceOf(InteractionModel::instance()),
265  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
267  }
268 
269  AGX_FORCE_INLINE InteractionPtr& InteractionPtr::operator= (const agxData::EntityPtr& ptr)
270  {
272  agxAssertN(!ptr || ptr.isInstanceOf(InteractionModel::instance()),
273  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
274  EntityPtr::getModel()->fullPath().c_str(), InteractionModel::instance()->fullPath().c_str());
275  return *this;
276  }
277 
278  AGX_FORCE_INLINE InteractionPtr& InteractionPtr::operator= (const agxData::EntityInstance& instance)
279  {
281  agxAssertN(!instance || instance.isInstanceOf(InteractionModel::instance()),
282  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
283  EntityPtr::getModel()->fullPath().c_str(), InteractionModel::instance()->fullPath().c_str());
284  return *this;
285  }
286 
287  inline InteractionInstance InteractionPtr::instance() { return agxData::EntityPtr::instance(); }
288  inline const InteractionInstance InteractionPtr::instance() const { return agxData::EntityPtr::instance(); }
289  AGX_FORCE_INLINE InteractionSemantics* InteractionPtr::operator->() { return (InteractionSemantics* )this; }
290  AGX_FORCE_INLINE const InteractionSemantics* InteractionPtr::operator->() const { return (const InteractionSemantics* )this; }
291  AGX_FORCE_INLINE InteractionData* InteractionPtr::getData() { return static_cast<InteractionData* >(agxData::EntityPtr::getData()); }
292  AGX_FORCE_INLINE const InteractionData* InteractionPtr::getData() const { return static_cast<const InteractionData* >(agxData::EntityPtr::getData()); }
293 
294  AGX_FORCE_INLINE agx::SolveModel*& InteractionPtr::solveModel() { verifyIndex(); return getData()->solveModel[calculateIndex()]; }
295  AGX_FORCE_INLINE agx::SolveModel* const& InteractionPtr::solveModel() const { verifyIndex(); return getData()->solveModel[calculateIndex()]; }
296 
297  AGX_FORCE_INLINE agx::Physics::GraphNodePtr& InteractionPtr::graphNode() { verifyIndex(); return getData()->graphNode[calculateIndex()]; }
298  AGX_FORCE_INLINE agx::Physics::GraphNodePtr const& InteractionPtr::graphNode() const { verifyIndex(); return getData()->graphNode[calculateIndex()]; }
299 
300  //-----------------------------------------------------------------------------------------------------
301  AGX_FORCE_INLINE InteractionInstance::InteractionInstance() {}
302  AGX_FORCE_INLINE InteractionInstance::InteractionInstance(InteractionData* data, agx::Index index) : agxData::EntityInstance(data, index) {}
303  AGX_FORCE_INLINE InteractionInstance::InteractionInstance(agxData::EntityStorage* storage, agx::Index index) : agxData::EntityInstance(storage, index) {}
304  AGX_FORCE_INLINE InteractionInstance::InteractionInstance(const agxData::EntityInstance& other) : agxData::EntityInstance(other)
305  {
307  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
309  }
310 
311  AGX_FORCE_INLINE InteractionInstance::InteractionInstance(const agxData::EntityPtr& ptr) : agxData::EntityInstance(ptr)
312  {
314  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
316  }
317 
318 
319  AGX_FORCE_INLINE InteractionData* InteractionInstance::getData() { return static_cast<InteractionData* >(agxData::EntityInstance::getData()); }
320  AGX_FORCE_INLINE const InteractionData* InteractionInstance::getData() const { return static_cast<const InteractionData* >(agxData::EntityInstance::getData()); }
321 
322  AGX_FORCE_INLINE agx::SolveModel*& InteractionInstance::solveModel() { verifyIndex(); return getData()->solveModel[getIndex()]; }
323  AGX_FORCE_INLINE agx::SolveModel* const& InteractionInstance::solveModel() const { verifyIndex(); return getData()->solveModel[getIndex()]; }
324 
325  AGX_FORCE_INLINE agx::Physics::GraphNodePtr& InteractionInstance::graphNode() { verifyIndex(); return getData()->graphNode[getIndex()]; }
326  AGX_FORCE_INLINE agx::Physics::GraphNodePtr const& InteractionInstance::graphNode() const { verifyIndex(); return getData()->graphNode[getIndex()]; }
327 
328  //-----------------------------------------------------------------------------------------------------
329  AGX_FORCE_INLINE InteractionSemantics::InteractionSemantics() {}
330  //-----------------------------------------------------------------------------------------------------
332  }
333 }
334 
335 AGX_TYPE_BINDING(agx::Physics::InteractionPtr, "Physics.InteractionPtr")
336 AGX_TYPE_BINDING(agx::Physics::InteractionInstance, "Physics.InteractionInstance")
337 
338 #ifdef _MSC_VER
339 # pragma warning(pop)
340 #endif
341 
342 #undef AGX_ENTITY_WRAPPER
343 #undef AGX_ENTITY_NAMESPACE
344 #endif
345 
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGX_TYPE_BINDING(_Type, _Name)
Definition: Type.h:179
#define AGXPHYSICS_EXPORT
Type-specific Array used for fast access into the data held by a Buffer.
Definition: Array.h:107
Entity instance provides access to a single instance in an EntityStorage.
bool isInstanceOf(agxData::EntityModel *model) const
agxData::EntityData * getData()
An abstract description of a data entity stored using SOA (structure of arrays) pattern in a EntitySt...
Definition: EntityModel.h:64
Accessor to a entity instance stored in a EntityStorage, to allow SOA (structure of arrays) data to b...
Definition: EntityPtr.h:52
bool isInstanceOf(agxData::EntityModel *model) const
agxData::EntityData * getData()
agxData::EntityInstance instance()
Definition: EntityPtr.h:269
EntityPtr & operator=(const EntityPtr &other)=default
Data storage for a collection of entity instances of a specified EntityModel.
Definition: EntityStorage.h:73
agx::String fullPath() const
Pointer to a entity instance of type Physics.GraphNode.
Abstract description of the data attributes for the Physics.Interaction entity.
virtual void initAttributeAccessors() override
virtual agxData::EntityData * createData(agxData::EntityStorage *storage) override
virtual void shutdownCleanup() override
This is part of internal cleanup and should not be called by users.
void construct(agx::Physics::InteractionPtr interaction)
static InteractionModel * instance()
static agxData::PointerAttributeT< agx::SolveModel * > * solveModelAttribute
static InteractionPtr createInstance()
Create and return a pointer to a new instance in the default storage for this entity model.
static agxData::ScalarAttributeT< agx::Physics::GraphNodePtr > * graphNodeAttribute
InteractionModel(const agx::String &name="Interaction")
virtual void configure(agx::TiXmlElement *eEntity) override
virtual void construct(agxData::EntityPtr instance) override
static agxData::EntityStorage * defaultStorage()
Pointer to a entity instance of type Physics.Interaction.
AGXPHYSICS_EXPORT InteractionPtr()
AGXPHYSICS_EXPORT agx::SolveModel *& solveModel()
AGXPHYSICS_EXPORT InteractionSemantics * operator->()
AGXPHYSICS_EXPORT InteractionPtr(const agxData::EntityInstance &instance)
InteractionData * getData()
InteractionInstance InstanceType
AGXPHYSICS_EXPORT agx::Physics::GraphNodePtr const & graphNode() const
AGXPHYSICS_EXPORT InteractionPtr(const agxData::EntityPtr &ptr)
AGXPHYSICS_EXPORT const InteractionInstance instance() const
AGXPHYSICS_EXPORT InteractionInstance instance()
const InteractionData * getData() const
AGXPHYSICS_EXPORT InteractionPtr(agxData::EntityStorage *storage, agx::Index id)
AGXPHYSICS_EXPORT const InteractionSemantics * operator->() const
AGXPHYSICS_EXPORT agx::Physics::GraphNodePtr & graphNode()
AGXPHYSICS_EXPORT agx::SolveModel *const & solveModel() const
Vector containing 'raw' data.
Definition: agx/Vector.h:246
#define agxAssertN(expr, format,...)
Definition: debug.h:145
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define CALLABLE
Definition: macros.h:72
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
#define AGX_FORCE_INLINE
Definition: macros.h:58
Contains classes for low level data storage for AGX.
Definition: Container.h:23
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
AGXCORE_EXPORT Model * getModel(const Path &path, const Path &_namespace=Path())
Definition: Object.h:364
UInt32 Index
Definition: Integer.h:52