OsgUniform.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_GRAPHICS_OSGUNIFORM_H
17 #define SURGSIM_GRAPHICS_OSGUNIFORM_H
18 
21 
22 namespace YAML
23 {
24 class Node;
25 }
26 
27 namespace SurgSim
28 {
29 
30 namespace Graphics
31 {
32 
35 template <class T>
36 class OsgUniform : public Uniform<T>, public OsgUniformBase
37 {
38 public:
41  explicit OsgUniform(const std::string& name);
42 
45  virtual void set(const T& value);
46 
49  virtual void set(const YAML::Node& node);
50 
52  virtual const T& get() const;
53 
54 private:
57 };
58 
61 template <class T>
62 class OsgUniform<std::vector<T>> : public Uniform<std::vector<T>>, public OsgUniformBase
63 {
64 public:
68  OsgUniform(const std::string& name, size_t numElements);
69 
71  virtual size_t getNumElements() const;
72 
76  virtual void setElement(size_t index, const T& value);
77 
80  virtual void set(const std::vector<T>& value);
81 
85  virtual void set(const YAML::Node& node);
86 
90  virtual typename std::vector<T>::const_reference getElement(size_t index) const;
91 
94  virtual const std::vector<T>& get() const;
95 
96 private:
98  std::vector<T> m_value;
99 };
100 
101 }; // namespace Graphics
102 
103 }; // namespace SurgSim
104 
106 
113 
114 #endif // SURGSIM_GRAPHICS_OSGUNIFORM_H
SurgSim::Graphics::OsgUniformBase
Base OSG implementation of graphics uniforms.
Definition: OsgUniformBase.h:42
OsgUniform-inl.h
SurgSim::Graphics::OsgUniform::set
virtual void set(const T &value)
Sets the value of the uniform.
Definition: OsgUniform-inl.h:53
Uniform.h
YAML
Definition: DataStructuresConvert.h:29
SurgSim
Definition: CompoundShapeToGraphics.cpp:30
SurgSim::Graphics::OsgUniform::get
virtual const T & get() const
Definition: OsgUniform-inl.h:67
SurgSim::Graphics::OsgUniform
OSG implementation of graphics uniform with a value of type T.
Definition: OsgUniform.h:37
OsgTextureUniform.h
OsgTextureUniform-inl.h
SurgSim::Graphics::OsgUniform::OsgUniform
OsgUniform(const std::string &name)
Constructor.
Definition: OsgUniform-inl.h:43
SurgSim::Graphics::OsgUniform::m_value
T m_value
Value of the uniform.
Definition: OsgUniform.h:56
OsgUniformBase.h
string
string(TOUPPER ${DEVICE} DEVICE_UPPER_CASE) option(BUILD_DEVICE_$
Definition: CMakeLists.txt:38
SurgSim::Graphics::OsgUniform< std::vector< T > >::m_value
std::vector< T > m_value
Vector containing the values of the uniform's elements.
Definition: OsgUniform.h:98
SurgSim::Graphics::Uniform
Base class for a graphics uniform with a value of type T.
Definition: Uniform.h:33