VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtUniqueElementAttribute.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2021 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvCore/vrvCore.h>
13 #include <vrvCore/DtElementEntry.h>
14 #include <vrvUtil/DtUnicode.h>
15 
16 #include <string>
17 
18 namespace makVrv
19 {
20  template <typename Type>
21  struct TypeIds;
22 
23  namespace EntityStateListener
24  {
25  enum class DamageState;
26  }
27 
28  //Macro simply define once before the element attribute.
29 #define AddTypeId(typeStr, number)\
30  template <> struct TypeIds<typeStr> { enum { id = number }; }
31 
32  typedef std::pair<int, int> pairInts;
33 
34  //Add default built in types
35  AddTypeId(unsigned char, 1);
36  AddTypeId(unsigned short, 2);
37  AddTypeId(unsigned int, 3);
38  AddTypeId(unsigned long int, 4);
39  AddTypeId(char, 5);
40  AddTypeId(short, 6);
41  AddTypeId(int, 7);
42  AddTypeId(long int, 8);
43  AddTypeId(float, 9);
44  AddTypeId(double, 10);
45  AddTypeId(bool, 11);
46  AddTypeId(std::string, 12);
47  AddTypeId(pairInts, 13);
48  AddTypeId(DtUnicode, 14);
50 
51  template <typename T>
53  {
54  public:
55  DtTypedElementAttribute(unsigned short attrId, const T& value)
56  : DtElementAttribute(attrId, TypeIds<T>::id)
57  , myValue(value)
58  {
59  }
60 
62  {
63  }
64 
66  virtual DtElementAttribute* clone() const
67  {
69  }
70 
71  inline const T& value() const
72  {
73  return myValue;
74  }
75 
76  private:
77  T myValue;
78  };
79 
80  template <typename T, unsigned short AttributeId>
82  {
83  public:
85  : DtTypedElementAttribute<T>(AttributeId, value)
86  {
87  }
88 
90  {
91 
92  }
93 
95  virtual DtElementAttribute* clone() const
96  {
98  }
99 
102  {
103  return dynamic_cast<const DtUniqueElementAttribute<T,AttributeId>*>(entry.findAttribute(AttributeId));
104  }
105  };
106 }
107 
108 #define DtUniqueElementAttribute_INL_
109 #include <vrvCore/DtUniqueElementAttribute.inl>
110 #undef DtUniqueElementAttribute_INL_
111 
112 
std::pair< int, int > pairInts
Definition: DtUniqueElementAttribute.h:32
A unicode string. DtUnicode stores a UTF-16 encoded unicode string. Code Point, a Unicode character...
Definition: DtUnicode.h:33
Definition: DtUniqueElementAttribute.h:21
Definition: DtUniqueElementAttribute.h:52
DamageState
Definition: DtEntityStateListener.h:64
const T & value() const
Definition: DtUniqueElementAttribute.h:71
virtual ~DtTypedElementAttribute()
Definition: DtUniqueElementAttribute.h:61
DtElementEntry holds the non-simulation-specific data about an element, including its element type an...
Definition: DtElementEntry.h:22
T myValue
Definition: DtUniqueElementAttribute.h:77
const DtElementAttribute * findAttribute(short attributeId) const
Find an existing attribute.
DtTypedElementAttribute(unsigned short attrId, const T &value)
Definition: DtUniqueElementAttribute.h:55
static const DtUniqueElementAttribute< T, AttributeId > * findInEntry(const DtElementEntry &entry)
Attempt to find an attribute in an entry.
Definition: DtUniqueElementAttribute.h:101
virtual ~DtUniqueElementAttribute()
Definition: DtUniqueElementAttribute.h:89
virtual DtElementAttribute * clone() const
Virtual Clone function.
Definition: DtUniqueElementAttribute.h:95
virtual DtElementAttribute * clone() const
Virtual Clone function.
Definition: DtUniqueElementAttribute.h:66
DtElementAttribute is a common base class used for all element attributes, such as those found in a D...
Definition: DtElementAttribute.h:20
Definition: DtUniqueElementAttribute.h:81
unsigned short attributeId() const
Definition: DtElementAttribute.h:34
DtUniqueElementAttribute(const T &value)
Definition: DtUniqueElementAttribute.h:84
AddTypeId(makVrv::DtUniqueID, 20)
Contains makVrv::DtElementEntry class.
Contains DLL export macros.

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)