vrecko
virtual reality framework
 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 
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 
150 
166 
167 // end of vrecko namespace
168 }
169 
170 // end header definitions
171 #endif
172