VR-Forces 4.8 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) 2019 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);
44 
45  template <typename T>
47  {
48  public:
49  DtTypedElementAttribute(unsigned short attrId, const T& value)
50  : DtElementAttribute(attrId, TypeIds<T>::id)
51  , myValue(value)
52  {
53  }
54 
56  {
57  }
58 
60  virtual DtElementAttribute* clone() const
61  {
63  }
64 
65  inline const T& value() const
66  {
67  return myValue;
68  }
69 
70  private:
71  T myValue;
72  };
73 
74  template <typename T, unsigned short AttributeId>
76  {
77  public:
79  : DtTypedElementAttribute<T>(AttributeId, value)
80  {
81  }
82 
84  {
85 
86  }
87 
89  virtual DtElementAttribute* clone() const
90  {
92  }
93 
96  {
97  return dynamic_cast<const DtUniqueElementAttribute<T,AttributeId>*>(entry.findAttribute(AttributeId));
98  }
99  };
100 }
101 
102 #define DtUniqueElementAttribute_INL_
103 #include <vrvCore/DtUniqueElementAttribute.inl>
104 #undef DtUniqueElementAttribute_INL_
105 
106 
std::pair< int, int > pairInts
Definition: DtUniqueElementAttribute.h:27
A unicode string.
Definition: DtUnicode.h:33
Definition: DtUniqueElementAttribute.h:21
Definition: DtUniqueElementAttribute.h:46
const T & value() const
Definition: DtUniqueElementAttribute.h:65
virtual ~DtTypedElementAttribute()
Definition: DtUniqueElementAttribute.h:55
DtElementEntry holds the non-simulation-specific data about an element, including its element type an...
Definition: DtElementEntry.h:22
T myValue
Definition: DtUniqueElementAttribute.h:71
const DtElementAttribute * findAttribute(short attributeId) const
Find an existing attribute.
DtTypedElementAttribute(unsigned short attrId, const T &value)
Definition: DtUniqueElementAttribute.h:49
static const DtUniqueElementAttribute< T, AttributeId > * findInEntry(const DtElementEntry &entry)
Attempt to find an attribute in an entry.
Definition: DtUniqueElementAttribute.h:95
virtual ~DtUniqueElementAttribute()
Definition: DtUniqueElementAttribute.h:83
virtual DtElementAttribute * clone() const
Virtual Clone function.
Definition: DtUniqueElementAttribute.h:89
virtual DtElementAttribute * clone() const
Virtual Clone function.
Definition: DtUniqueElementAttribute.h:60
DtElementAttribute is a common base class used for all element attributes, such as those found in a D...
Definition: DtElementAttribute.h:23
Definition: DtUniqueElementAttribute.h:75
unsigned short attributeId() const
Definition: DtElementAttribute.h:37
DtUniqueElementAttribute(const T &value)
Definition: DtUniqueElementAttribute.h:78
AddTypeId(makVrv::DtUniqueID, 20)
Contains makVrv::DtElementEntry class.
Contains DLL export macros.

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)