VISR  0.11.1
Versatile Interactive Scene Renderer
float_sequence.hpp
Go to the documentation of this file.
1 /* Copyright Institute of Sound and Vibration Research - All rights reserved */
2 
3 #ifndef VISR_RBBL_FLOAT_SEQUENCE_HPP_INCLUDED
4 #define VISR_RBBL_FLOAT_SEQUENCE_HPP_INCLUDED
5 
6 #include "export_symbols.hpp"
7 
8 #include <algorithm>
9 #include <ciso646>
10 #include <initializer_list>
11 #include <stdexcept>
12 #include <string>
13 #include <vector>
14 
15 namespace visr
16 {
17 namespace rbbl
18 {
19 
24 template<typename ElementType>
25 class VISR_RBBL_LIBRARY_SYMBOL FloatSequence
26 {
27 public:
28  using ContainerType = std::vector<ElementType>;
29 
33  FloatSequence();
34 
38  explicit FloatSequence( ElementType val, std::size_t num = 1);
39 
45  explicit FloatSequence( ElementType const * const val, std::size_t numValues );
46 
51  explicit FloatSequence( std::initializer_list<ElementType> const & val );
52 
57  explicit FloatSequence( std::string const & val );
58 
59  std::size_t size() const
60  {
61  return mValues.size();
62  }
63 
64  ElementType * values()
65  {
66  return &mValues[0];
67  }
68 
69  ElementType const * values() const
70  {
71  return &mValues[0];
72  }
73 
74  typename ContainerType::const_iterator begin() const
75  {
76  return mValues.begin();
77  }
78 
79  typename ContainerType::const_iterator end() const
80  {
81  return mValues.end();
82  }
83 
84  typename ContainerType::iterator begin()
85  {
86  return mValues.begin();
87  }
88 
89  typename ContainerType::iterator end()
90  {
91  return mValues.end();
92  }
93 
97  ElementType & operator[]( std::size_t idx )
98  {
99  return mValues[idx];
100  }
101 
105  ElementType const & operator[]( std::size_t idx ) const
106  {
107  return mValues[idx];
108  }
109 
113  ElementType & at( std::size_t idx )
114  {
115  return mValues.at( idx );
116  }
117 
121  ElementType const & at( std::size_t idx ) const
122  {
123  return mValues.at( idx );
124  }
125 
129  void clear();
130 
136  std::string toString( std::string const & separator=std::string(", ") ) const;
137 private:
138  ContainerType mValues;
139 };
140 
141 } // namespace rbbl
142 } // namespace visr
143 
144 
145 #endif // VISR_RBBL_FLOAT_SEQUENCE_HPP_INCLUDED
ContainerType::iterator begin()
Definition: float_sequence.hpp:84
std::vector< ElementType > ContainerType
Definition: float_sequence.hpp:28
ContainerType::iterator end()
Definition: float_sequence.hpp:89
ElementType & at(std::size_t idx)
Definition: float_sequence.hpp:113
ContainerType::const_iterator begin() const
Definition: float_sequence.hpp:74
ElementType const & at(std::size_t idx) const
Definition: float_sequence.hpp:121
ContainerType::const_iterator end() const
Definition: float_sequence.hpp:79
Definition: options.cpp:10
ElementType const * values() const
Definition: float_sequence.hpp:69
ElementType const & operator[](std::size_t idx) const
Definition: float_sequence.hpp:105
std::size_t size() const
Definition: float_sequence.hpp:59
ElementType & operator[](std::size_t idx)
Definition: float_sequence.hpp:97
Definition: float_sequence.hpp:25
ElementType * values()
Definition: float_sequence.hpp:64