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;
61 Vector(std::initializer_list<ValueType> init);
89 for (
size_t i = 0; i < N; ++i)
91 m_data[i] =
static_cast<ValueType
>(other[i]);
104 size_t size()
const {
return N; }
109 inline ValueType
at(
size_t index)
const {
return m_data[index]; }
114 inline void setAt(
size_t index, ValueType value) { m_data[index] = value; }
116 inline ValueType operator[](
size_t index)
const {
return m_data[index]; }
117 inline ValueType& operator[](
size_t index) {
return m_data[index]; }
138 Iterator begin() noexcept {
return m_data.begin(); }
139 ConstIterator begin() const noexcept {
return m_data.begin(); }
140 Iterator end() noexcept {
return m_data.end(); }
141 ConstIterator end() const noexcept {
return m_data.end(); }
143 bool operator==(
const Vector& other)
const;
144 bool operator!=(
const Vector& other)
const;
146 std::string toString()
const;
160 Vector& operator*=(ValueType value);
161 Vector& operator/=(ValueType value);
163 inline Vector operator*(ValueType v)
const {
return Vector(*
this) *= v; }
164 inline Vector operator/(ValueType v)
const {
return Vector(*
this) /= v; }
166 friend inline Vector operator*(ValueType value,
Vector v) {
return v *= value; }
190 bool operator<(
const Vector& other)
const;
191 bool operator<=(
const Vector& other)
const;
192 bool operator>(
const Vector& other)
const;
193 bool operator>=(
const Vector& other)
const;
195 operator VectorX<ValueType>()
const;
198 std::array<ValueType, N> m_data;
201 template <
typename T,
size_t N>
203 operator<<(std::ostream& os,
const Vector<T, N>& v)
216 extern template class IOLINK_API_IMPORT Vector<int8_t, 2>;
217 extern template class IOLINK_API_IMPORT Vector<int16_t, 2>;
218 extern template class IOLINK_API_IMPORT Vector<int32_t, 2>;
219 extern template class IOLINK_API_IMPORT Vector<int64_t, 2>;
221 extern template class IOLINK_API_IMPORT Vector<uint8_t, 2>;
222 extern template class IOLINK_API_IMPORT Vector<uint16_t, 2>;
223 extern template class IOLINK_API_IMPORT Vector<uint32_t, 2>;
224 extern template class IOLINK_API_IMPORT Vector<uint64_t, 2>;
226 extern template class IOLINK_API_IMPORT Vector<float, 2>;
227 extern template class IOLINK_API_IMPORT Vector<double, 2>;
232 extern template class IOLINK_API_IMPORT Vector<int8_t, 3>;
233 extern template class IOLINK_API_IMPORT Vector<int16_t, 3>;
234 extern template class IOLINK_API_IMPORT Vector<int32_t, 3>;
235 extern template class IOLINK_API_IMPORT Vector<int64_t, 3>;
237 extern template class IOLINK_API_IMPORT Vector<uint8_t, 3>;
238 extern template class IOLINK_API_IMPORT Vector<uint16_t, 3>;
239 extern template class IOLINK_API_IMPORT Vector<uint32_t, 3>;
240 extern template class IOLINK_API_IMPORT Vector<uint64_t, 3>;
242 extern template class IOLINK_API_IMPORT Vector<float, 3>;
243 extern template class IOLINK_API_IMPORT Vector<double, 3>;
248 extern template class IOLINK_API_IMPORT Vector<int8_t, 4>;
249 extern template class IOLINK_API_IMPORT Vector<int16_t, 4>;
250 extern template class IOLINK_API_IMPORT Vector<int32_t, 4>;
251 extern template class IOLINK_API_IMPORT Vector<int64_t, 4>;
253 extern template class IOLINK_API_IMPORT Vector<uint8_t, 4>;
254 extern template class IOLINK_API_IMPORT Vector<uint16_t, 4>;
255 extern template class IOLINK_API_IMPORT Vector<uint32_t, 4>;
256 extern template class IOLINK_API_IMPORT Vector<uint64_t, 4>;
258 extern template class IOLINK_API_IMPORT Vector<float, 4>;
259 extern template class IOLINK_API_IMPORT Vector<double, 4>;