VR-Forces 4.10 Class Documentation
 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  //Macro simply define once before the element attribute.
24 #define AddTypeId(typeStr, number)\
25  template <> struct TypeIds<typeStr> { enum { id = number }; }
26 
27  typedef std::pair<int, int> pairInts;
28 
29  //Add default built in types
30  AddTypeId(unsigned char, 1);
31  AddTypeId(unsigned short, 2);
32  AddTypeId(unsigned int, 3);
33  AddTypeId(unsigned long int, 4);
34  AddTypeId(char, 5);
35  AddTypeId(short, 6);
36  AddTypeId(int, 7);
37  AddTypeId(long int, 8);
38  AddTypeId(float, 9);
39  AddTypeId(double, 10);
40  AddTypeId(bool, 11);
41  AddTypeId(std::string, 12);
42  AddTypeId(pairInts, 13);
43  AddTypeId(DtUnicode, 14);
45 
46  template <typename T>
48  {
49  public:
50  DtTypedElementAttribute(unsigned short attrId, const T& value)
51  : DtElementAttribute(attrId, TypeIds<T>::id)
52  , myValue(value)
53  {
54  }
55 
57  {
58  }
59 
61  virtual DtElementAttribute* clone() const
62  {
64  }
65 
66  inline const T& value() const
67  {
68  return myValue;
69  }
70 
71  private:
72  T myValue;
73  };
74 
75  template <typename T, unsigned short AttributeId>
77  {
78  public:
80  : DtTypedElementAttribute<T>(AttributeId, value)
81  {
82  }
83 
85  {
86 
87  }
88 
90  virtual DtElementAttribute* clone() const
91  {
93  }
94 
97  {
98  return dynamic_cast<const DtUniqueElementAttribute<T,AttributeId>*>(entry.findAttribute(AttributeId));
99  }
100  };
101 }
102 
103 #define DtUniqueElementAttribute_INL_
104 #include <vrvCore/DtUniqueElementAttribute.inl>
105 #undef DtUniqueElementAttribute_INL_
106 
107 
std::pair< int, int > pairInts
Definition: DtUniqueElementAttribute.h:27
A unicode string.
Definition: DtUnicode.h:33
Definition: DtUniqueElementAttribute.h:21
Definition: DtUniqueElementAttribute.h:47
const T & value() const
Definition: DtUniqueElementAttribute.h:66
virtual ~DtTypedElementAttribute()
Definition: DtUniqueElementAttribute.h:56
DtElementEntry holds the non-simulation-specific data about an element, including its element type an...
Definition: DtElementEntry.h:22
T myValue
Definition: DtUniqueElementAttribute.h:72
const DtElementAttribute * findAttribute(short attributeId) const
Find an existing attribute.
DtTypedElementAttribute(unsigned short attrId, const T &value)
Definition: DtUniqueElementAttribute.h:50
static const DtUniqueElementAttribute< T, AttributeId > * findInEntry(const DtElementEntry &entry)
Attempt to find an attribute in an entry.
Definition: DtUniqueElementAttribute.h:96
virtual ~DtUniqueElementAttribute()
Definition: DtUniqueElementAttribute.h:84
virtual DtElementAttribute * clone() const
Virtual Clone function.
Definition: DtUniqueElementAttribute.h:90
virtual DtElementAttribute * clone() const
Virtual Clone function.
Definition: DtUniqueElementAttribute.h:61
DamageState
Definition: DtEntityStateListener.h:88
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:76
unsigned short attributeId() const
Definition: DtElementAttribute.h:34
DtUniqueElementAttribute(const T &value)
Definition: DtUniqueElementAttribute.h:79
AddTypeId(makVrv::DtUniqueID, 20)
Contains makVrv::DtElementEntry class.
Contains DLL export macros.

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)