AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
EntityInstance.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGXDATA_ENTITYINSTANCE_H
18#define AGXDATA_ENTITYINSTANCE_H
19
20#include <agx/agx.h>
21#include <agx/Integer.h>
22#include <agx/hash.h>
23// #include <agxData/EntityData.h>
24
25namespace agxData
26{
27 class EntityStorage;
28 class EntityData;
29 class EntityModel;
30 class EntityPtr;
31 typedef agxData::EntityData* EntityDataPtr;
32
33
44 {
45 public:
49 EntityInstance(agxData::EntityData* data, agx::Index index);
52
54 ~EntityInstance() = default;
55
61 void init(agxData::EntityData* data, agx::Index index);
62
66 agx::Index getIndex() const;
67
71 agx::Index calculateId() const;
72
76 agxData::EntityData* getData();
77 const agxData::EntityData* getData() const;
78
83 agxData::EntityStorage* getStorage();
84 const agxData::EntityStorage* getStorage() const;
85
90 agxData::EntityModel* getModel();
91 const agxData::EntityModel* getModel() const;
92
96 bool isInstanceOf(agxData::EntityModel* model) const;
97
101 bool isValid() const;
102
106 void verifyIndex() const;
107
108
109 // Hash function
110 agx::UInt32 hash() const;
111
113 bool operator!() const;
114 operator bool() const;
115
116 bool operator<( const EntityInstance& rhs ) const;
117 bool operator>( const EntityInstance& rhs ) const;
118
119 bool operator==( const EntityInstance& rhs ) const;
120 bool operator!=( const EntityInstance& rhs ) const;
121
122 static void TransformToAscii(void *targetBuffer, const void *sourceBuffer, size_t numElements);
123
124 private:
125
126 EntityDataPtr m_data;
127 agx::Index m_index;
128 };
129
130
131 AGXCORE_EXPORT std::ostream& operator << (std::ostream& output, const EntityInstance& entity);
132
133 /* Implementation */
134 AGX_FORCE_INLINE EntityInstance::EntityInstance() : m_data(nullptr), m_index(agx::InvalidIndex)
135 {}
136
137 AGX_FORCE_INLINE EntityInstance::EntityInstance(agxData::EntityData* data, agx::Index index) : m_data(data), m_index(index)
138 {}
139
140
143
144
145 AGX_FORCE_INLINE void EntityInstance::init(agxData::EntityData* data, agx::Index index) { m_data = data; m_index = index; }
146
148
149 AGX_FORCE_INLINE agxData::EntityData* EntityInstance::getData() { return m_data; }
150 AGX_FORCE_INLINE const agxData::EntityData* EntityInstance::getData() const { return m_data; }
151
153 {
154 return agx::hash( agx::hash( m_data ), agx::hash( m_index ) );
155 }
156
157 AGX_FORCE_INLINE bool EntityInstance::isValid() const { return m_data != nullptr; }
158 AGX_FORCE_INLINE bool EntityInstance::operator!() const { return !this->isValid(); }
159 AGX_FORCE_INLINE EntityInstance::operator bool() const { return this->isValid(); }
160
162 {
163 return this->getIndex() < rhs.getIndex();
164 }
165
167 {
168 return this->getIndex() > rhs.getIndex();
169 }
170
172 {
173 return (this->getStorage() == rhs.getStorage()) && (this->getIndex() == rhs.getIndex());
174 }
175
177 {
178 return (this->getStorage() != rhs.getStorage()) || (this->getIndex() != rhs.getIndex());
179 }
180
181
182}
183
184
185#endif /* AGXDATA_ENTITYINSTANCE_H */
#define AGXCORE_EXPORT
Entity instance provides access to a single instance in an EntityStorage.
~EntityInstance()=default
Destructor.
bool operator!() const
Boolean operators, implemented using isValid.
bool operator<(const EntityInstance &rhs) const
void init(agxData::EntityData *data, agx::Index index)
Initialize an instance.
bool operator!=(const EntityInstance &rhs) const
agx::UInt32 hash() const
agx::Index getIndex() const
bool operator==(const EntityInstance &rhs) const
bool operator>(const EntityInstance &rhs) const
EntityInstance()
Constructors.
static void TransformToAscii(void *targetBuffer, const void *sourceBuffer, size_t numElements)
agxData::EntityStorage * getStorage()
Alias for getData()->getStorage()
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
Data storage for a collection of entity instances of a specified EntityModel.
Only use as member allocated variable.
Definition Value.h:285
#define AGX_FORCE_INLINE
Definition macros.h:58
Contains classes for low level data storage for AGX.
Definition Container.h:23
std::ostream & operator<<(std::ostream &output, const Attribute &attribute)
agxData::EntityData * EntityDataPtr
Definition EntityData.h:152
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t UInt32
Definition Integer.h:32
AGXCORE_EXPORT UInt32 hash(const T &key)
UInt32 Index
Definition Integer.h:44