Uniform.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_UNIFORM_H
17 #define SURGSIM_GRAPHICS_UNIFORM_H
18 
20 
21 #include <vector>
22 
23 namespace SurgSim
24 {
25 
26 namespace Graphics
27 {
28 
31 template <class T>
32 class Uniform : public virtual UniformBase
33 {
34 public:
35 
36  Uniform() {
38  }
39 
41  virtual void set(const T& value) = 0;
42 
44  virtual const T& get() const = 0;
45 };
46 
49 template <class T>
50 class Uniform<std::vector<T>> : public virtual UniformBase
51 {
52 public:
54  virtual size_t getNumElements() const = 0;
55 
59  virtual void setElement(size_t index, const T& value) = 0;
60 
63  virtual void set(const std::vector<T>& value) = 0;
64 
68  virtual typename std::vector<T>::const_reference getElement(size_t index) const = 0;
69 
72  virtual const std::vector<T>& get() const = 0;
73 };
74 
75 }; // namespace Graphics
76 
77 }; // namespace SurgSim
78 
79 #endif // SURGSIM_GRAPHICS_UNIFORM_H
SURGSIM_ADD_RW_PROPERTY
#define SURGSIM_ADD_RW_PROPERTY(class, type, property, getter, setter)
A macro to register getter and setter for a property that is readable and writeable,...
Definition: Accessible.h:213
SurgSim::Graphics::Uniform< std::vector< T > >::getNumElements
virtual size_t getNumElements() const =0
Returns the number of elements.
SurgSim::Graphics::Uniform::set
virtual void set(const T &value)=0
Sets the value of the uniform.
SurgSim::Graphics::Uniform::get
virtual const T & get() const =0
Returns the value of the uniform.
SurgSim
Definition: CompoundShapeToGraphics.cpp:30
SurgSim::Graphics::Uniform< std::vector< T > >::get
virtual const std::vector< T > & get() const =0
Gets the value of all of the uniform's elements.
SurgSim::Graphics::Uniform::Uniform
Uniform()
Definition: Uniform.h:36
SurgSim::Graphics::Uniform< std::vector< T > >::setElement
virtual void setElement(size_t index, const T &value)=0
Sets the value of one of the uniform's elements.
SurgSim::Graphics::Uniform< std::vector< T > >::getElement
virtual std::vector< T >::const_reference getElement(size_t index) const =0
Gets the value of one of the uniform's elements.
SurgSim::Graphics::UniformBase
Common base class for all graphics uniforms.
Definition: UniformBase.h:34
SurgSim::Graphics::Uniform< std::vector< T > >::set
virtual void set(const std::vector< T > &value)=0
Sets the value of all of the uniform's elements.
UniformBase.h
SurgSim::Graphics::Uniform
Base class for a graphics uniform with a value of type T.
Definition: Uniform.h:33