AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
Attribute.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. 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_ATTRIBUTE_H
18#define AGXDATA_ATTRIBUTE_H
19
20#ifdef _MSC_VER
21# pragma warning(push)
22// warning C4505: 'agxData::VectorAttributeT<T>::print' : unreferenced local function has been removed
23# pragma warning( disable : 4505 )
24#endif
25
26#include <agx/agx.h>
27#include <agx/agxCore_export.h>
28#include <agx/String.h>
29#include <agx/Object.h>
30#include <agx/Vector.h>
31#include <agxData/Value.h>
32#include <iosfwd>
33
34
35namespace agx
36{
37 class TiXmlElement;
38}
39
40namespace agxData
41{
42 class EntityModel;
43 class Type;
44
45 template<typename T>
46 class Array;
47
52
53
58 {
59 public:
61
62 public:
63
69 Attribute(const agx::Name& name, agxData::Type *type, agxData::Format *defaultFormat = nullptr, agxData::Value *defaultValue = nullptr, agxData::Value *numElements = nullptr);
70
74 agx::Index getId() const;
75
80 const agxData::Type *getType() const;
81
86
90 agxData::Format *getDefaultFormat();
91 const agxData::Format *getDefaultFormat() const;
92
96 agxData::Value *getNumElements();
97 const agxData::Value *getNumElements() const;
98
102 agxData::Value *getDefaultValue();
103 const agxData::Value *getDefaultValue() const;
104
105
109 EntityModel *getEntity() const;
110
113
114 protected:
115 virtual ~Attribute();
116 Attribute() : Object(""), m_entity(0) {}
117 friend class EntityModel;
118 friend class EntityStorage;
120 void setEntity(EntityModel *entity);
121
122 private:
123 agx::Index m_id;
124 TypeRef m_type;
125 FormatRef m_defaultFormat;
126 agxData::ValueRef m_defaultValue;
127 agxData::ValueRef m_numElements;
128 EntityModel *m_entity;
129 };
130
131
132 std::ostream& operator << (std::ostream& output, const Attribute& attribute);
133
134
139 {
140 public:
141 static ScalarAttribute *load(agx::TiXmlElement *eAttribute);
143
145 const agx::Name& name, Type* type, Format* defaultFormat = nullptr, agxData::Value* defaultValue = nullptr,
146 agxData::Value* numElementsExpression = nullptr);
147
148 protected:
150
151 private:
152 };
153
158 {
159 public:
160 static PointerAttribute *load(agx::TiXmlElement *eAttribute);
162
163 PointerAttribute(const agx::Name& name, Type *type, Format *defaultFormat = nullptr, agxData::Value *defaultValue = nullptr);
164
165 protected:
167
168 private:
169 };
170
175 {
176 public:
177 static SharedAttribute *load(agx::TiXmlElement *eAttribute);
179
180 public:
181 SharedAttribute(const agx::Name& name, Format *format, const agx::String& expression);
182
183 // agxData::Value *getValue() { return m_value; }
184 const agx::String& getExpression() const { return m_expression; }
185
186 protected:
188 private:
189 // agxData::ValueRef m_value;
190 agx::String m_expression;
191 };
192
193
194
199 {
200 public:
202
203 ContainerAttribute(const agx::Name& name, ScalarAttribute *elementAttribute, Type *containerType);
204 ScalarAttribute *getElementAttribute();
205 const ScalarAttribute *getElementAttribute() const;
207
208 protected:
210 private:
211 ScalarAttributeRef m_elementAttribute;
212 };
213
214
219 {
220 public:
221 static ArrayAttribute *load(agx::TiXmlElement *eAttribute);
223
224
225 public:
226 ArrayAttribute(const agx::Name& name, ScalarAttribute *elementAttribute, Type *arrayType);
228
229 protected:
231 private:
232 };
233
234
239 {
240 public:
241 static VectorAttribute *load(agx::TiXmlElement *eAttribute);
243
244
245 public:
246 VectorAttribute(const agx::Name& name, ScalarAttribute *elementAttribute, Type *vectorType);
248
249 protected:
251 private:
252 };
253
254
259 {
260 public:
261 static HashSetAttribute *load(agx::TiXmlElement *eAttribute);
263
264
265 public:
266 HashSetAttribute(const agx::Name& name, ScalarAttribute *elementAttribute, Type* hashSetType);
268
269 protected:
271 private:
272 };
273
274
275
276 //--- TEMPLATED ----
277
278 template <typename T>
280 {
281 public:
282 typedef T Type;
283
285 //ScalarAttributeT() {}
286 virtual ~ScalarAttributeT() {}
287 private:
288 // T m_defaultValue;
289 };
290
291 template <typename T>
293 {
294 public:
295 typedef T Type;
296
297 private:
299 virtual ~PointerAttributeT() {}
300 // T m_defaultValue;
301 };
302
303 template <typename T>
305 {
306 public:
307 typedef Array<T> Type;
308 typedef T ElementType;
309
310 private:
311 ArrayAttributeT() {}
312 virtual ~ArrayAttributeT() {}
313 // Array<T> m_defaultValue;
314 // ScalarAttributeT<T> m_elementAttribute;
315 };
316
317 template <typename T>
319 {
320 public:
322 typedef T ElementType;
323
324 private:
326 virtual ~VectorAttributeT() {}
327 // Type m_defaultValue;
328 ScalarAttributeT<T> m_elementAttribute;
329 };
330
331 template <typename T>
333 {
334 public:
335 typedef agx::HashSet<T> Type; // NOTE agx::HashSet instead of agxData::HashSet due to pointer invalidation (element buffer) in recursive HashSet::rebuild calls
336 typedef T ElementType;
337
338 private:
340 virtual ~HashSetAttributeT() {}
341 // Type m_defaultValue;
342 ScalarAttributeT<T> m_elementAttribute;
343 };
344
345
346
347 template <typename T>
349 {
350 public:
351 typedef T Type;
352
353 private:
355 virtual ~SharedAttributeT() {}
356 // T m_defaultValue;
357 };
358
359
360
361
362 /* Implementation */
363
364 //-- ATTRIBUTE ----------------------
367 AGX_FORCE_INLINE const Type *Attribute::getType() const { return m_type; }
369 AGX_FORCE_INLINE const Format *Attribute::getDefaultFormat() const { return m_defaultFormat; }
371 AGX_FORCE_INLINE const agxData::Value *Attribute::getNumElements() const { return m_numElements; }
373 AGX_FORCE_INLINE const agxData::Value *Attribute::getDefaultValue() const { return m_defaultValue; }
375
376
377
378 //-- CONTAINER ATTRIBUTE --------------------------
381
382}
383
384#ifdef _MSC_VER
385# pragma warning(pop)
386#endif
387#endif /* _AGXDATA_ATTRIBUTE_H_ */
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXCORE_EXPORT
An array attribute.
Definition: Attribute.h:219
static ArrayAttribute * load(agx::TiXmlElement *eAttribute)
ArrayAttribute(const agx::Name &name, ScalarAttribute *elementAttribute, Type *arrayType)
static agx::Model * ClassModel()
Type-specific Array used for fast access into the data held by a Buffer.
Definition: Array.h:107
An abstract attribute description, part of an Entity.
Definition: Attribute.h:58
void setEntity(EntityModel *entity)
void setDefaultFormat(agxData::Format *format)
agx::String fullName() const
EntityModel * getEntity() const
Definition: Attribute.h:374
void setDefaultValue(agxData::Value *value)
Attribute(const agx::Name &name, agxData::Type *type, agxData::Format *defaultFormat=nullptr, agxData::Value *defaultValue=nullptr, agxData::Value *numElements=nullptr)
Constructor.
void setId(agx::Index id)
agxData::Value * getDefaultValue()
Definition: Attribute.h:372
agxData::Format * getDefaultFormat()
Definition: Attribute.h:368
static agx::Model * ClassModel()
virtual ~Attribute()
agxData::Type * getType()
Definition: Attribute.h:366
agxData::Value * getNumElements()
Definition: Attribute.h:370
agx::Index getId() const
Definition: Attribute.h:365
A container attribute (Array/Vector/HashSet)
Definition: Attribute.h:199
static agx::Model * ClassModel()
ContainerAttribute(const agx::Name &name, ScalarAttribute *elementAttribute, Type *containerType)
ScalarAttribute * getElementAttribute()
Definition: Attribute.h:380
An abstract description of a data entity stored using SOA (structure of arrays) pattern in a EntitySt...
Definition: EntityModel.h:64
Data storage for a collection of entity instances of a specified EntityModel.
Definition: EntityStorage.h:73
A format is an implementation of a agxData::Type.
Definition: Format.h:64
agx::HashSet< T > Type
Definition: Attribute.h:335
A hash set attribute.
Definition: Attribute.h:259
HashSetAttribute(const agx::Name &name, ScalarAttribute *elementAttribute, Type *hashSetType)
static agx::Model * ClassModel()
static HashSetAttribute * load(agx::TiXmlElement *eAttribute)
A pointer attribute.
Definition: Attribute.h:158
static PointerAttribute * load(agx::TiXmlElement *eAttribute)
PointerAttribute(const agx::Name &name, Type *type, Format *defaultFormat=nullptr, agxData::Value *defaultValue=nullptr)
static agx::Model * ClassModel()
ScalarAttributeT(const agx::Name &name)
Definition: Attribute.h:284
A scalar attribute.
Definition: Attribute.h:139
ScalarAttribute(const agx::Name &name, Type *type, Format *defaultFormat=nullptr, agxData::Value *defaultValue=nullptr, agxData::Value *numElementsExpression=nullptr)
static ScalarAttribute * load(agx::TiXmlElement *eAttribute)
static agx::Model * ClassModel()
A shared attribute.
Definition: Attribute.h:175
SharedAttribute(const agx::Name &name, Format *format, const agx::String &expression)
const agx::String & getExpression() const
Definition: Attribute.h:184
static agx::Model * ClassModel()
static SharedAttribute * load(agx::TiXmlElement *eAttribute)
Abstracted type.
Definition: Type.h:98
Abstract representation of a value.
Definition: Value.h:49
agx::Vector< T > Type
Definition: Attribute.h:321
A vector attribute.
Definition: Attribute.h:239
static VectorAttribute * load(agx::TiXmlElement *eAttribute)
VectorAttribute(const agx::Name &name, ScalarAttribute *elementAttribute, Type *vectorType)
static agx::Model * ClassModel()
Inheritance with partial specialization due to bug with ref_ptr containers.
Definition: agx/HashSet.h:670
A model is an abstract representation of the class of an agx::Object.
Definition: Model.h:41
Representation of a name string.
Definition: Name.h:33
agx::Object is a refcounted object with a name.
Definition: Object.h:59
Templated vector class.
Definition: agx/Vector.h:53
#define AGX_FORCE_INLINE
Definition: macros.h:58
Contains classes for low level data storage for AGX.
Definition: Container.h:23
Format * getFormat()
Definition: Type.h:269
AGXCORE_EXPORT Type * getType(const agx::String &name)
std::ostream & operator<<(std::ostream &output, const Attribute &attribute)
AGXCORE_EXPORT EntityModel * getEntity(const agx::Path &path)
Get a entity with a specified path.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
UInt32 Index
Definition: Integer.h:44