VR-Forces 4.1 Class Documentation
DtUniqueElementAttribute.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2009 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: DtUniqueElementAttribute.h,v $ $Revision: 1.2 $ $State: Exp $
7 *******************************************************************************/
8 
12 
13 #pragma once
14 
15 #include <vrvCore/vrvCore.h>
16 #include <vrvCore/DtElementEntry.h>
17 
18 #include <string>
19 
20 namespace makVrv
21 {
22  template <typename Type>
23  struct TypeIds;
24 
25  //Macro simply define once before the element attribute.
26 #define AddTypeId(typeStr, number)\
27  template <> struct TypeIds<typeStr> { enum { id = number }; }
28 
29  typedef std::pair<int, int> pairInts;
30 
31  //Add default built in types
32  AddTypeId(unsigned char, 1);
33  AddTypeId(unsigned short, 2);
34  AddTypeId(unsigned int, 3);
35  AddTypeId(unsigned long int, 4);
36  AddTypeId(char, 5);
37  AddTypeId(short, 6);
38  AddTypeId(int, 7);
39  AddTypeId(long int, 8);
40  AddTypeId(float, 9);
41  AddTypeId(double, 10);
42  AddTypeId(bool, 11);
43  AddTypeId(std::string, 12);
44  AddTypeId(pairInts, 13);
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 

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)