vrecko
virtual reality framework
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
StaticAttribute.h
Go to the documentation of this file.
1
13
// header definitions
14
#ifndef _STATIC_ATTRIBUTE_H_
15
#define _STATIC_ATTRIBUTE_H_
16
17
// attributes description includes
18
#include "
Attribute.h
"
19
#include "
Range.h
"
20
21
// STL includes
22
#include <string>
23
24
// OSG includes
25
#include <osg/Vec2>
26
#include <osg/Vec3>
27
#include <osg/Vec4>
28
#include <osg/Matrix>
29
#include <osg/Quat>
30
31
// namespaces used
32
using namespace
std;
33
using namespace
osg;
34
35
// VRECKO namespace
36
namespace
vrecko
37
{
38
64
template
<Attribute::DataType type,
class
tval,
class
tref = tval>
65
class
StaticAttribute
:
public
Attribute
66
{
67
public
:
68
83
StaticAttribute
(
const
string
& strName,
const
string
& strDescription, tref defaultValue,
84
Range
* pRange =
null
) :
Attribute
(strName,
type
, strDescription)
85
{
86
// initialize both attributes
87
this->defaultValue = defaultValue;
88
this->pRange = pRange;
89
}
90
94
~
StaticAttribute
()
95
{
96
// if the range pointer is not null
97
if
(pRange !=
null
)
98
{
99
// delete and null the pointer
100
delete
pRange;
101
pRange =
null
;
102
}
103
}
104
110
inline
tref getDefaultValue()
const
111
{
112
return
defaultValue;
113
}
114
120
inline
const
Range
* getRangePtr()
const
121
{
122
return
pRange;
123
}
124
130
inline
bool
hasRange()
const
131
{
132
return
(getRangePtr() !=
null
);
133
}
134
135
private
:
136
137
// specialized attribute attributes
138
tval defaultValue;
139
Range
* pRange;
140
};
141
145
typedef
StaticAttribute<Attribute::TYPE_BOOL, bool>
BoolAttribute
;
146
typedef
StaticAttribute<Attribute::TYPE_INT, int>
IntAttribute
;
147
typedef
StaticAttribute<Attribute::TYPE_LONG, long>
LongAttribute
;
148
typedef
StaticAttribute<Attribute::TYPE_FLOAT, float>
FloatAttribute
;
149
typedef
StaticAttribute<Attribute::TYPE_DOUBLE, double>
DoubleAttribute
;
150
154
typedef
StaticAttribute<Attribute::TYPE_STRING, string, const string&>
155
StringAttribute
;
156
typedef
StaticAttribute<Attribute::TYPE_VEC2, Vec2, const Vec2&>
157
Vec2Attribute
;
158
typedef
StaticAttribute<Attribute::TYPE_VEC3, Vec3, const Vec3&>
159
Vec3Attribute
;
160
typedef
StaticAttribute<Attribute::TYPE_VEC4, Vec4, const Vec4&>
161
Vec4Attribute
;
162
typedef
StaticAttribute<Attribute::TYPE_MATRIX, Matrix, const Matrix&>
163
MatrixAttribute
;
164
typedef
StaticAttribute<Attribute::TYPE_QUAT, Quat, const Quat&>
165
QuatAttribute
;
166
167
// end of vrecko namespace
168
}
169
170
// end header definitions
171
#endif
172
include
vrecko
StaticAttribute.h
Generated on Tue Feb 19 2013 10:23:41 for vrecko by
1.8.3.1