AGX Dynamics  2.37.2.0
AttributeContainer.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 having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 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 
17 #ifndef AGXDATA_ATTRIBUTECONTAINER_H
18 #define AGXDATA_ATTRIBUTECONTAINER_H
19 
20 #include <agx/agx.h>
21 #include <agxData/Attribute.h>
22 #include <agx/agxCore_export.h>
23 #include <agx/Allocator.h>
24 #include <agx/HashTable.h>
25 
26 namespace agxData
27 {
32  {
33  public:
36 
40  void *getAttribute(const Attribute *attribute);
41  const void *getAttribute(const Attribute *attribute) const;
42 
43 
44  // Templated accessors
45  template <typename T>
46  T& getAttribute(const ScalarAttributeT<T> *attribute);
47 
48  template <typename T>
49  const T& getAttribute(const ScalarAttributeT<T> *attribute) const;
50 
51 
55  bool hasAttribute(const Attribute *attribute) const;
56 
57  private:
59  mutable ScalarAttributeTable m_attributeTable;
60  };
61 
62 
63  /* Implementation */
64  template <typename T>
66  {
67  return *static_cast<T *>(this->getAttribute(static_cast<const Attribute *>(attribute)));
68  }
69 
70  template <typename T>
71  const T& AttributeContainer::getAttribute(const ScalarAttributeT<T> *attribute) const
72  {
73  return const_cast<AttributeContainer *>(this)->getAttribute(attribute);
74  }
75 
76 }
77 
78 
79 #endif /* _AGXDATA_ATTRIBUTECONTAINER_H_ */
An attribute container.
void * getAttribute(const Attribute *attribute)
An abstract attribute description, part of an Entity.
Definition: Attribute.h:57
Contains classes for low level data storage for AGX.
Definition: Container.h:23
Inheritance with partial specialization due to bug with ref_ptr containers.
#define AGXCORE_EXPORT