3 #include <iolink/IOLinkAPI.h>
4 #include <iolink/VectorX.h>
8 #include <initializer_list>
35 template <
typename T,
size_t N>
41 using Iterator =
typename std::array<T, N>::iterator;
42 using ConstIterator =
typename std::array<T, N>::const_iterator;
59 Vector(std::initializer_list<ValueType> init);
87 for (
size_t i = 0; i < N; ++i)
89 m_data[i] =
static_cast<ValueType
>(other[i]);
102 size_t size()
const {
return N; }
107 inline ValueType
at(
size_t index)
const {
return m_data[index]; }
112 inline void setAt(
size_t index, ValueType value) { m_data[index] = value; }
114 inline ValueType operator[](
size_t index)
const {
return m_data[index]; }
115 inline ValueType& operator[](
size_t index) {
return m_data[index]; }
136 Iterator begin() noexcept {
return m_data.begin(); }
137 ConstIterator begin() const noexcept {
return m_data.begin(); }
138 Iterator end() noexcept {
return m_data.end(); }
139 ConstIterator end() const noexcept {
return m_data.end(); }
141 bool operator==(
const Vector& other)
const;
142 bool operator!=(
const Vector& other)
const;
144 std::string toString()
const;
158 Vector& operator*=(ValueType value);
159 Vector& operator/=(ValueType value);
161 inline Vector operator*(ValueType v)
const {
return Vector(*
this) *= v; }
162 inline Vector operator/(ValueType v)
const {
return Vector(*
this) /= v; }
164 friend inline Vector operator*(ValueType value,
Vector v) {
return v *= value; }
188 bool operator<(
const Vector& other)
const;
189 bool operator<=(
const Vector& other)
const;
190 bool operator>(
const Vector& other)
const;
191 bool operator>=(
const Vector& other)
const;
193 operator VectorX<ValueType>()
const;
196 std::array<ValueType, N> m_data;
199 template <
typename T,
size_t N>
201 operator<<(std::ostream& os,
const Vector<T, N>& v)
214 extern template class IOLINK_API_IMPORT Vector<int8_t, 2>;
215 extern template class IOLINK_API_IMPORT Vector<int16_t, 2>;
216 extern template class IOLINK_API_IMPORT Vector<int32_t, 2>;
217 extern template class IOLINK_API_IMPORT Vector<int64_t, 2>;
219 extern template class IOLINK_API_IMPORT Vector<uint8_t, 2>;
220 extern template class IOLINK_API_IMPORT Vector<uint16_t, 2>;
221 extern template class IOLINK_API_IMPORT Vector<uint32_t, 2>;
222 extern template class IOLINK_API_IMPORT Vector<uint64_t, 2>;
224 extern template class IOLINK_API_IMPORT Vector<float, 2>;
225 extern template class IOLINK_API_IMPORT Vector<double, 2>;
230 extern template class IOLINK_API_IMPORT Vector<int8_t, 3>;
231 extern template class IOLINK_API_IMPORT Vector<int16_t, 3>;
232 extern template class IOLINK_API_IMPORT Vector<int32_t, 3>;
233 extern template class IOLINK_API_IMPORT Vector<int64_t, 3>;
235 extern template class IOLINK_API_IMPORT Vector<uint8_t, 3>;
236 extern template class IOLINK_API_IMPORT Vector<uint16_t, 3>;
237 extern template class IOLINK_API_IMPORT Vector<uint32_t, 3>;
238 extern template class IOLINK_API_IMPORT Vector<uint64_t, 3>;
240 extern template class IOLINK_API_IMPORT Vector<float, 3>;
241 extern template class IOLINK_API_IMPORT Vector<double, 3>;
246 extern template class IOLINK_API_IMPORT Vector<int8_t, 4>;
247 extern template class IOLINK_API_IMPORT Vector<int16_t, 4>;
248 extern template class IOLINK_API_IMPORT Vector<int32_t, 4>;
249 extern template class IOLINK_API_IMPORT Vector<int64_t, 4>;
251 extern template class IOLINK_API_IMPORT Vector<uint8_t, 4>;
252 extern template class IOLINK_API_IMPORT Vector<uint16_t, 4>;
253 extern template class IOLINK_API_IMPORT Vector<uint32_t, 4>;
254 extern template class IOLINK_API_IMPORT Vector<uint64_t, 4>;
256 extern template class IOLINK_API_IMPORT Vector<float, 4>;
257 extern template class IOLINK_API_IMPORT Vector<double, 4>;