VR-Forces 4.5 Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
include
vrvCore
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>
47
class
DtTypedElementAttribute
:
public
DtElementAttribute
48
{
49
public
:
50
DtTypedElementAttribute
(
unsigned
short
attrId,
const
T&
value
)
51
:
DtElementAttribute
(attrId, TypeIds<T>::id)
52
,
myValue
(value)
53
{
54
}
55
56
virtual
~DtTypedElementAttribute
()
57
{
58
}
59
61
virtual
DtElementAttribute
*
clone
()
const
62
{
63
return
new
DtTypedElementAttribute
(
attributeId
(),
value
());
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>
76
class
DtUniqueElementAttribute
:
public
DtTypedElementAttribute
<T>
77
{
78
public
:
79
DtUniqueElementAttribute
(
const
T&
value
)
80
:
DtTypedElementAttribute
<T>(AttributeId, value)
81
{
82
}
83
84
virtual
~DtUniqueElementAttribute
()
85
{
86
87
}
88
90
virtual
DtElementAttribute
*
clone
()
const
91
{
92
return
new
DtUniqueElementAttribute<T,AttributeId>
(this->
value
());
93
}
94
96
static
const
DtUniqueElementAttribute<T,AttributeId>
*
findInEntry
(
const
DtElementEntry
& entry)
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 Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (
www.mak.com
)