IOLink  IOL_v1.6.1_release
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 
87  T at(const VectorXu64& index) const;
88 
95  void setAt(const VectorXu64& index, T value);
96 
102  void reshape(const VectorXu64& shape);
103 
107  const T* buffer() const;
108 
112  T* buffer();
113 
117  std::string toString() const;
118 
119  bool operator==(const ArrayX& other) const;
120 
121  bool operator!=(const ArrayX& other) const;
122 
123 private:
124  class Private;
125  Private* m_private;
126 };
127 
128 // ===================== //
129 // Template declarations //
130 // ===================== //
131 
132 extern template class IOLINK_API_IMPORT ArrayX<int8_t>;
133 extern template class IOLINK_API_IMPORT ArrayX<int16_t>;
134 extern template class IOLINK_API_IMPORT ArrayX<int32_t>;
135 extern template class IOLINK_API_IMPORT ArrayX<int64_t>;
136 extern template class IOLINK_API_IMPORT ArrayX<uint8_t>;
137 extern template class IOLINK_API_IMPORT ArrayX<uint16_t>;
138 extern template class IOLINK_API_IMPORT ArrayX<uint32_t>;
139 extern template class IOLINK_API_IMPORT ArrayX<uint64_t>;
140 extern template class IOLINK_API_IMPORT ArrayX<float>;
141 extern template class IOLINK_API_IMPORT ArrayX<double>;
142 
143 //==================== //
144 // Aliases declaration //
145 //==================== //
146 
157 
158 } // end namespace iolink