AGX Dynamics  2.35.0.1
GraphNodeEntity.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_GRAPHNODE_H_PLUGIN
22 #define GENERATED_AGX_PHYSICS_GRAPHNODE_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>
47 #include <agx/Integer.h>
48 
49 namespace agxData { class EntityPtr; }
50 
51 namespace agx
52 {
53  namespace Physics
54  {
55 
56  class GraphNodeModel;
57  class GraphNodeData;
58  class GraphNodePtr;
59  class GraphNodeInstance;
60  class GraphNodeSemantics;
61 
62 
64 
69  {
70  public:
71  typedef GraphNodePtr PtrT;
72 
73  GraphNodeModel(const agx::String& name = "GraphNode");
74 
77 
80 
83 
85  virtual void shutdownCleanup() override;
86 
87 
88 
89  /* Attributes */
98 
99  protected:
100  virtual ~GraphNodeModel();
101  virtual agxData::EntityData* createData(agxData::EntityStorage* storage) override;
102  virtual void configure(agx::TiXmlElement* eEntity) override;
103  virtual void initAttributeAccessors() override;
104  virtual void construct(agxData::EntityPtr instance) override;
106  };
107 
108 
110  #ifndef AGX_PHYSICS_GRAPHNODE_DATA_SET_OVERRIDE
111  #define AGX_PHYSICS_GRAPHNODE_DATA_SET
112  class AGXPHYSICS_EXPORT GraphNodeData : public agxData::EntityData
113  {
114  public:
115  GraphNodeInstance operator[] (size_t index);
116 
117  public:
127 
128  public:
129  typedef agxData::EntityPtr sourceType;
130  typedef agx::UInt8 typeType;
131  typedef agx::UInt8 stateType;
132  typedef agx::UInt32 colorType;
133  typedef agx::UInt32 tagType;
134  typedef agxData::Array< agx::UInt > edgesType;
135  typedef agx::UInt32 islandType;
136  typedef agx::UInt32 subindexType;
137 
138  public:
139  GraphNodeData(agxData::EntityStorage* storage);
140  GraphNodeData();
141 
142  protected:
143  virtual ~GraphNodeData() {}
144  virtual void setNumElements(agx::Index numElements) override;
145 
146  private:
147  GraphNodeData& operator= (const GraphNodeData&) { return *this; }
148 
149  };
150  #endif
152 
153 
155  class AGXPHYSICS_EXPORT GraphNodeSemantics : protected agxData::EntityPtr
156  {
157  public:
158 
159  // Automatic getters
160  agxData::EntityPtr const& getSource() const;
161  agx::UInt8 const& getType() const;
162  agx::UInt8 const& getState() const;
163  agx::UInt32 const& getColor() const;
164  agx::UInt32 const& getTag() const;
165  agxData::Array< agx::UInt > const& getEdges() const;
166  agx::UInt32 const& getIsland() const;
167  agx::UInt32 const& getSubindex() const;
168 
169  // Semantics defined by explicit kernels
170 
171  // Automatic setters
172  void setSource(agxData::EntityPtr const& value);
173  void setType(agx::UInt8 const& value);
174  void setState(agx::UInt8 const& value);
175  void setColor(agx::UInt32 const& value);
176  void setTag(agx::UInt32 const& value);
177  void setEdges(agxData::Array< agx::UInt > const& value);
178  void setIsland(agx::UInt32 const& value);
179  void setSubindex(agx::UInt32 const& value);
180 
181 
182  protected:
183  friend class GraphNodePtr;
184  friend class GraphNodeInstance;
185  GraphNodeSemantics();
186  };
188 
189 
190 
193  class CALLABLE GraphNodePtr : public agxData::EntityPtr
194  {
195  public:
197  typedef GraphNodeData DataType;
198  typedef GraphNodeInstance InstanceType;
199 
200  public:
207  AGXPHYSICS_EXPORT GraphNodeInstance instance();
208  AGXPHYSICS_EXPORT const GraphNodeInstance instance() const;
209 
210  AGXPHYSICS_EXPORT GraphNodeSemantics* operator->();
211  AGXPHYSICS_EXPORT const GraphNodeSemantics* operator->() const;
212 
213  GraphNodeData* getData();
214  const GraphNodeData* getData() const;
215 
216 
221 
226 
231 
236 
241 
246 
251 
256 
258  // Only used by tolua!
259  #ifdef AGX_GENERATED_TOLUA_WRAPPER
260  inline agxData::EntityPtr const& getSource() const { return (*this)->getSource(); }
261  inline agx::UInt8 const& getType() const { return (*this)->getType(); }
262  inline agx::UInt8 const& getState() const { return (*this)->getState(); }
263  inline agx::UInt32 const& getColor() const { return (*this)->getColor(); }
264  inline agx::UInt32 const& getTag() const { return (*this)->getTag(); }
265  inline agxData::Array< agx::UInt > const& getEdges() const { return (*this)->getEdges(); }
266  inline agx::UInt32 const& getIsland() const { return (*this)->getIsland(); }
267  inline agx::UInt32 const& getSubindex() const { return (*this)->getSubindex(); }
268 
269 
270  inline void setSource(agxData::EntityPtr const& value) { (*this)->setSource(value); }
271  inline void setType(agx::UInt8 const& value) { (*this)->setType(value); }
272  inline void setState(agx::UInt8 const& value) { (*this)->setState(value); }
273  inline void setColor(agx::UInt32 const& value) { (*this)->setColor(value); }
274  inline void setTag(agx::UInt32 const& value) { (*this)->setTag(value); }
275  inline void setEdges(agxData::Array< agx::UInt > const& value) { (*this)->setEdges(value); }
276  inline void setIsland(agx::UInt32 const& value) { (*this)->setIsland(value); }
277  inline void setSubindex(agx::UInt32 const& value) { (*this)->setSubindex(value); }
278  #endif
280 
281  };
282 
283 
285  class AGXPHYSICS_EXPORT GraphNodeInstance : public agxData::EntityInstance
286  {
287  public:
288  GraphNodeInstance();
289  GraphNodeInstance(GraphNodeData* data, agx::Index index);
290  GraphNodeInstance(agxData::EntityStorage *storage, agx::Index index);
291  GraphNodeInstance(const agxData::EntityInstance& other);
292  GraphNodeInstance(const agxData::EntityPtr& ptr);
293 
294  GraphNodeData* getData();
295  const GraphNodeData* getData() const;
296 
297  public:
299  agxData::EntityPtr& source();
301  agxData::EntityPtr const& source() const;
302 
304  agx::UInt8& type();
306  agx::UInt8 const& type() const;
307 
309  agx::UInt8& state();
311  agx::UInt8 const& state() const;
312 
314  agx::UInt32& color();
316  agx::UInt32 const& color() const;
317 
319  agx::UInt32& tag();
321  agx::UInt32 const& tag() const;
322 
326  agxData::Array< agx::UInt > const& edges() const;
327 
329  agx::UInt32& island();
331  agx::UInt32 const& island() const;
332 
334  agx::UInt32& subindex();
336  agx::UInt32 const& subindex() const;
337 
338  };
340 
341 
342 
345 
346 
347 
349  /* Implementation */
350  //-----------------------------------------------------------------------------------------------------
351  //-----------------------------------------------------------------------------------------------------
352  inline GraphNodeInstance agx::Physics::GraphNodeData::operator[] (size_t index) { return GraphNodeInstance(this, (agx::Index)index); }
353  //-----------------------------------------------------------------------------------------------------
355  AGX_FORCE_INLINE GraphNodePtr::GraphNodePtr(agxData::EntityStorage* storage, agx::Index id) : agxData::EntityPtr(storage, id) {}
356  AGX_FORCE_INLINE GraphNodePtr::GraphNodePtr(const agxData::EntityPtr& ptr) : agxData::EntityPtr(ptr)
357  {
359  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
361  }
362 
363  AGX_FORCE_INLINE GraphNodePtr::GraphNodePtr(const agxData::EntityInstance& instance) : agxData::EntityPtr(instance)
364  {
365  agxAssertN(!instance || instance.isInstanceOf(GraphNodeModel::instance()),
366  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
368  }
369 
370  AGX_FORCE_INLINE GraphNodePtr& GraphNodePtr::operator= (const agxData::EntityPtr& ptr)
371  {
373  agxAssertN(!ptr || ptr.isInstanceOf(GraphNodeModel::instance()),
374  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
375  EntityPtr::getModel()->fullPath().c_str(), GraphNodeModel::instance()->fullPath().c_str());
376  return *this;
377  }
378 
379  AGX_FORCE_INLINE GraphNodePtr& GraphNodePtr::operator= (const agxData::EntityInstance& instance)
380  {
382  agxAssertN(!instance || instance.isInstanceOf(GraphNodeModel::instance()),
383  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
384  EntityPtr::getModel()->fullPath().c_str(), GraphNodeModel::instance()->fullPath().c_str());
385  return *this;
386  }
387 
388  inline GraphNodeInstance GraphNodePtr::instance() { return agxData::EntityPtr::instance(); }
389  inline const GraphNodeInstance GraphNodePtr::instance() const { return agxData::EntityPtr::instance(); }
390  AGX_FORCE_INLINE GraphNodeSemantics* GraphNodePtr::operator->() { return (GraphNodeSemantics* )this; }
391  AGX_FORCE_INLINE const GraphNodeSemantics* GraphNodePtr::operator->() const { return (const GraphNodeSemantics* )this; }
392  AGX_FORCE_INLINE GraphNodeData* GraphNodePtr::getData() { return static_cast<GraphNodeData* >(agxData::EntityPtr::getData()); }
393  AGX_FORCE_INLINE const GraphNodeData* GraphNodePtr::getData() const { return static_cast<const GraphNodeData* >(agxData::EntityPtr::getData()); }
394 
395  AGX_FORCE_INLINE agxData::EntityPtr& GraphNodePtr::source() { verifyIndex(); return getData()->source[calculateIndex()]; }
396  AGX_FORCE_INLINE agxData::EntityPtr const& GraphNodePtr::source() const { verifyIndex(); return getData()->source[calculateIndex()]; }
397 
398  AGX_FORCE_INLINE agx::UInt8& GraphNodePtr::type() { verifyIndex(); return getData()->type[calculateIndex()]; }
399  AGX_FORCE_INLINE agx::UInt8 const& GraphNodePtr::type() const { verifyIndex(); return getData()->type[calculateIndex()]; }
400 
401  AGX_FORCE_INLINE agx::UInt8& GraphNodePtr::state() { verifyIndex(); return getData()->state[calculateIndex()]; }
402  AGX_FORCE_INLINE agx::UInt8 const& GraphNodePtr::state() const { verifyIndex(); return getData()->state[calculateIndex()]; }
403 
404  AGX_FORCE_INLINE agx::UInt32& GraphNodePtr::color() { verifyIndex(); return getData()->color[calculateIndex()]; }
405  AGX_FORCE_INLINE agx::UInt32 const& GraphNodePtr::color() const { verifyIndex(); return getData()->color[calculateIndex()]; }
406 
407  AGX_FORCE_INLINE agx::UInt32& GraphNodePtr::tag() { verifyIndex(); return getData()->tag[calculateIndex()]; }
408  AGX_FORCE_INLINE agx::UInt32 const& GraphNodePtr::tag() const { verifyIndex(); return getData()->tag[calculateIndex()]; }
409 
410  AGX_FORCE_INLINE agxData::Array< agx::UInt >& GraphNodePtr::edges() { verifyIndex(); return getData()->edges[calculateIndex()]; }
411  AGX_FORCE_INLINE agxData::Array< agx::UInt > const& GraphNodePtr::edges() const { verifyIndex(); return getData()->edges[calculateIndex()]; }
412 
413  AGX_FORCE_INLINE agx::UInt32& GraphNodePtr::island() { verifyIndex(); return getData()->island[calculateIndex()]; }
414  AGX_FORCE_INLINE agx::UInt32 const& GraphNodePtr::island() const { verifyIndex(); return getData()->island[calculateIndex()]; }
415 
416  AGX_FORCE_INLINE agx::UInt32& GraphNodePtr::subindex() { verifyIndex(); return getData()->subindex[calculateIndex()]; }
417  AGX_FORCE_INLINE agx::UInt32 const& GraphNodePtr::subindex() const { verifyIndex(); return getData()->subindex[calculateIndex()]; }
418 
419  //-----------------------------------------------------------------------------------------------------
420  AGX_FORCE_INLINE GraphNodeInstance::GraphNodeInstance() {}
421  AGX_FORCE_INLINE GraphNodeInstance::GraphNodeInstance(GraphNodeData* data, agx::Index index) : agxData::EntityInstance(data, index) {}
422  AGX_FORCE_INLINE GraphNodeInstance::GraphNodeInstance(agxData::EntityStorage* storage, agx::Index index) : agxData::EntityInstance(storage, index) {}
423  AGX_FORCE_INLINE GraphNodeInstance::GraphNodeInstance(const agxData::EntityInstance& other) : agxData::EntityInstance(other)
424  {
426  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
428  }
429 
430  AGX_FORCE_INLINE GraphNodeInstance::GraphNodeInstance(const agxData::EntityPtr& ptr) : agxData::EntityInstance(ptr)
431  {
433  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
435  }
436 
437 
438  AGX_FORCE_INLINE GraphNodeData* GraphNodeInstance::getData() { return static_cast<GraphNodeData* >(agxData::EntityInstance::getData()); }
439  AGX_FORCE_INLINE const GraphNodeData* GraphNodeInstance::getData() const { return static_cast<const GraphNodeData* >(agxData::EntityInstance::getData()); }
440 
441  AGX_FORCE_INLINE agxData::EntityPtr& GraphNodeInstance::source() { verifyIndex(); return getData()->source[getIndex()]; }
442  AGX_FORCE_INLINE agxData::EntityPtr const& GraphNodeInstance::source() const { verifyIndex(); return getData()->source[getIndex()]; }
443 
444  AGX_FORCE_INLINE agx::UInt8& GraphNodeInstance::type() { verifyIndex(); return getData()->type[getIndex()]; }
445  AGX_FORCE_INLINE agx::UInt8 const& GraphNodeInstance::type() const { verifyIndex(); return getData()->type[getIndex()]; }
446 
447  AGX_FORCE_INLINE agx::UInt8& GraphNodeInstance::state() { verifyIndex(); return getData()->state[getIndex()]; }
448  AGX_FORCE_INLINE agx::UInt8 const& GraphNodeInstance::state() const { verifyIndex(); return getData()->state[getIndex()]; }
449 
450  AGX_FORCE_INLINE agx::UInt32& GraphNodeInstance::color() { verifyIndex(); return getData()->color[getIndex()]; }
451  AGX_FORCE_INLINE agx::UInt32 const& GraphNodeInstance::color() const { verifyIndex(); return getData()->color[getIndex()]; }
452 
453  AGX_FORCE_INLINE agx::UInt32& GraphNodeInstance::tag() { verifyIndex(); return getData()->tag[getIndex()]; }
454  AGX_FORCE_INLINE agx::UInt32 const& GraphNodeInstance::tag() const { verifyIndex(); return getData()->tag[getIndex()]; }
455 
456  AGX_FORCE_INLINE agxData::Array< agx::UInt >& GraphNodeInstance::edges() { verifyIndex(); return getData()->edges[getIndex()]; }
457  AGX_FORCE_INLINE agxData::Array< agx::UInt > const& GraphNodeInstance::edges() const { verifyIndex(); return getData()->edges[getIndex()]; }
458 
459  AGX_FORCE_INLINE agx::UInt32& GraphNodeInstance::island() { verifyIndex(); return getData()->island[getIndex()]; }
460  AGX_FORCE_INLINE agx::UInt32 const& GraphNodeInstance::island() const { verifyIndex(); return getData()->island[getIndex()]; }
461 
462  AGX_FORCE_INLINE agx::UInt32& GraphNodeInstance::subindex() { verifyIndex(); return getData()->subindex[getIndex()]; }
463  AGX_FORCE_INLINE agx::UInt32 const& GraphNodeInstance::subindex() const { verifyIndex(); return getData()->subindex[getIndex()]; }
464 
465  //-----------------------------------------------------------------------------------------------------
466  AGX_FORCE_INLINE GraphNodeSemantics::GraphNodeSemantics() {}
467  //-----------------------------------------------------------------------------------------------------
469  }
470 }
471 
472 AGX_TYPE_BINDING(agx::Physics::GraphNodePtr, "Physics.GraphNodePtr")
473 AGX_TYPE_BINDING(agx::Physics::GraphNodeInstance, "Physics.GraphNodeInstance")
474 
475 #ifdef _MSC_VER
476 # pragma warning(pop)
477 #endif
478 
479 #undef AGX_ENTITY_WRAPPER
480 #undef AGX_ENTITY_NAMESPACE
481 #endif
482 
#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
Abstract description of the data attributes for the Physics.GraphNode entity.
static agxData::ScalarAttributeT< agxData::EntityPtr > * sourceAttribute
static agxData::ScalarAttributeT< agx::UInt32 > * tagAttribute
virtual void construct(agxData::EntityPtr instance) override
static agxData::ScalarAttributeT< agx::UInt8 > * typeAttribute
static agxData::ArrayAttributeT< agx::UInt > * edgesAttribute
static agxData::ScalarAttributeT< agx::UInt32 > * islandAttribute
static agxData::ScalarAttributeT< agx::UInt8 > * stateAttribute
static GraphNodePtr createInstance()
Create and return a pointer to a new instance in the default storage for this entity model.
static agxData::ScalarAttributeT< agx::UInt32 > * colorAttribute
static agxData::EntityStorage * defaultStorage()
virtual void shutdownCleanup() override
This is part of internal cleanup and should not be called by users.
virtual void configure(agx::TiXmlElement *eEntity) override
static GraphNodeModel * instance()
virtual agxData::EntityData * createData(agxData::EntityStorage *storage) override
GraphNodeModel(const agx::String &name="GraphNode")
static agxData::ScalarAttributeT< agx::UInt32 > * subindexAttribute
virtual void initAttributeAccessors() override
void construct(agx::Physics::GraphNodePtr graphNode)
Pointer to a entity instance of type Physics.GraphNode.
AGXPHYSICS_EXPORT GraphNodePtr(const agxData::EntityInstance &instance)
AGXPHYSICS_EXPORT const GraphNodeSemantics * operator->() const
AGXPHYSICS_EXPORT agx::UInt32 const & island() const
AGXPHYSICS_EXPORT agxData::EntityPtr const & source() const
AGXPHYSICS_EXPORT const GraphNodeInstance instance() const
AGXPHYSICS_EXPORT GraphNodeInstance instance()
GraphNodeData * getData()
AGXPHYSICS_EXPORT agx::UInt8 & state()
AGXPHYSICS_EXPORT agx::UInt32 & subindex()
AGXPHYSICS_EXPORT GraphNodeSemantics * operator->()
AGXPHYSICS_EXPORT agxData::Array< agx::UInt > & edges()
AGXPHYSICS_EXPORT agx::UInt8 & type()
AGXPHYSICS_EXPORT GraphNodePtr(agxData::EntityStorage *storage, agx::Index id)
AGXPHYSICS_EXPORT agxData::EntityPtr & source()
AGXPHYSICS_EXPORT agx::UInt32 const & color() const
AGXPHYSICS_EXPORT agx::UInt8 const & type() const
AGXPHYSICS_EXPORT agx::UInt8 const & state() const
GraphNodeInstance InstanceType
AGXPHYSICS_EXPORT agx::UInt32 & island()
AGXPHYSICS_EXPORT GraphNodePtr()
AGXPHYSICS_EXPORT agx::UInt32 & tag()
AGXPHYSICS_EXPORT agx::UInt32 & color()
AGXPHYSICS_EXPORT GraphNodePtr(const agxData::EntityPtr &ptr)
const GraphNodeData * getData() const
AGXPHYSICS_EXPORT agxData::Array< agx::UInt > const & edges() const
AGXPHYSICS_EXPORT agx::UInt32 const & tag() const
AGXPHYSICS_EXPORT agx::UInt32 const & subindex() 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
AGXCORE_EXPORT Type * getType(const agx::String &name)
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t UInt32
Definition: Integer.h:40
uint8_t UInt8
Definition: Integer.h:38
AGXCORE_EXPORT Model * getModel(const Path &path, const Path &_namespace=Path())
Definition: Object.h:364
UInt32 Index
Definition: Integer.h:52