IOLink  IOL_v1.1.0_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 
114 private:
115  class Private;
116  Private* m_private;
117 };
118 
119 // ===================== //
120 // Template declarations //
121 // ===================== //
122 
123 extern template class IOLINK_API_IMPORT ArrayX<int8_t>;
124 extern template class IOLINK_API_IMPORT ArrayX<int16_t>;
125 extern template class IOLINK_API_IMPORT ArrayX<int32_t>;
126 extern template class IOLINK_API_IMPORT ArrayX<int64_t>;
127 extern template class IOLINK_API_IMPORT ArrayX<uint8_t>;
128 extern template class IOLINK_API_IMPORT ArrayX<uint16_t>;
129 extern template class IOLINK_API_IMPORT ArrayX<uint32_t>;
130 extern template class IOLINK_API_IMPORT ArrayX<uint64_t>;
131 extern template class IOLINK_API_IMPORT ArrayX<float>;
132 extern template class IOLINK_API_IMPORT ArrayX<double>;
133 
134 //==================== //
135 // Aliases declaration //
136 //==================== //
137 
148 
149 } // end namespace iolink