| IOLink 1.11.0

Loading...
Searching...
No Matches
ArrayX.h
1#pragma once
2
3#include <iolink/IOLinkAPI.h>
4#include <iolink/Indexer.h>
5#include <iolink/VectorX.h>
6
7 namespace iolink
8{
9
29 template <typename T>
30 class ArrayX
31{
32 public:
36 using ValueType = T;
37
47 explicit ArrayX(const VectorXu64& shape);
48
54 explicit ArrayX(const Indexer& indexer);
55
56 // The following default implementations are needed
57 // for the Python wrapping.
58
59 ArrayX(const ArrayX& other);
60 ArrayX& operator=(const ArrayX& other);
61
62 ArrayX(ArrayX&& other) noexcept;
63 ArrayX& operator=(ArrayX&& other) noexcept;
64
65 ~ArrayX();
66
70 size_t dimensionCount() const;
71
75 const VectorXu64& shape() const;
76
80 const Indexer& indexer() const;
81
90 T at(const VectorXu64& index) const;
91
101 void setAt(const VectorXu64& index, T value);
102
108 void reshape(const VectorXu64& shape);
109
113 const T* buffer() const;
114
118 T* buffer();
119
123 std::string toString() const;
124
125 bool operator==(const ArrayX& other) const;
126
127 bool operator!=(const ArrayX& other) const;
128
129 private:
130 class Private;
131 Private* m_private;
132};
133
134// ===================== //
135// Template declarations //
136// ===================== //
137
138 extern template class IOLINK_API_IMPORT ArrayX<int8_t>;
139 extern template class IOLINK_API_IMPORT ArrayX<int16_t>;
140 extern template class IOLINK_API_IMPORT ArrayX<int32_t>;
141 extern template class IOLINK_API_IMPORT ArrayX<int64_t>;
142 extern template class IOLINK_API_IMPORT ArrayX<uint8_t>;
143 extern template class IOLINK_API_IMPORT ArrayX<uint16_t>;
144 extern template class IOLINK_API_IMPORT ArrayX<uint32_t>;
145 extern template class IOLINK_API_IMPORT ArrayX<uint64_t>;
146 extern template class IOLINK_API_IMPORT ArrayX<float>;
147 extern template class IOLINK_API_IMPORT ArrayX<double>;
148
149//==================== //
150// Aliases declaration //
151//==================== //
152
153 using ArrayXi8 = ArrayX<int8_t>;
154 using ArrayXi16 = ArrayX<int16_t>;
155 using ArrayXi32 = ArrayX<int32_t>;
156 using ArrayXi64 = ArrayX<int64_t>;
157 using ArrayXu8 = ArrayX<uint8_t>;
158 using ArrayXu16 = ArrayX<uint16_t>;
159 using ArrayXu32 = ArrayX<uint32_t>;
160 using ArrayXu64 = ArrayX<uint64_t>;
161 using ArrayXf = ArrayX<float>;
162 using ArrayXd = ArrayX<double>;
163
164} // end namespace iolink
iolink::ArrayX
A multi dimensionnal array.
Definition ArrayX.h:31
iolink::ArrayX::indexer
const Indexer & indexer() const
Return the indexer instance used by the array.
iolink::ArrayX::setAt
void setAt(const VectorXu64 &index, T value)
Set a value to an element of the array.
iolink::ArrayX::toString
std::string toString() const
Return a string representation.
iolink::ArrayX::ValueType
T ValueType
The data type of array's elements.
Definition ArrayX.h:36
iolink::ArrayX::buffer
T * buffer()
Return a non-const pointer to the internal buffer.
iolink::ArrayX::ArrayX
ArrayX(const VectorXu64 &shape)
Create an array with the given shape.
iolink::ArrayX::dimensionCount
size_t dimensionCount() const
The number of dimensions of the array.
iolink::ArrayX::reshape
void reshape(const VectorXu64 &shape)
Change the shape of the array.
iolink::ArrayX::at
T at(const VectorXu64 &index) const
Get an element of the array.
iolink::ArrayX::shape
const VectorXu64 & shape() const
Return the shape of the array.
iolink::ArrayX::ArrayX
ArrayX(const Indexer &indexer)
Create an array with a memory layout fitting the given indexer.
iolink::ArrayX::buffer
const T * buffer() const
Return a pointer to the internal buffer.
iolink::Indexer
This class is used to index a classic array into a multi dimensional array.
Definition Indexer.h:36
iolink::VectorX
A dynamically sized arithmetic vector.
Definition VectorX.h:18
iolink
All IOLink symbols are enclosed in this namespace.
Definition ArrayX.h:8