IOLink IOL_v1.8.0_release
Loading...
Searching...
No Matches
Serialization.h
1#pragma once
2
3#include <memory>
4
5#include <iolink/Matrix.h>
6#include <iolink/Vector.h>
7#include <iolink/VectorX.h>
8#include <iolink/storage/StreamAccess.h>
9#include <iolink/view/DataFrameView.h>
10#include <iolink/view/ImageView.h>
11
12namespace iolink
13{
14
19class IOLINK_API Serialization
20{
21public:
22 Serialization() = delete;
23 Serialization(const Serialization& other) = delete; // copy constructor
24 Serialization(Serialization&& other) = delete; // move constructor
25 Serialization& operator=(const Serialization& other) = delete; // copy assignment
26 Serialization& operator=(Serialization&& other) = delete; // move assignment
27
28 //================================================
29 // ImageView methods
30
31 // encode
38 static void encodeImageView(std::shared_ptr<ImageView> image, std::shared_ptr<StreamAccess> outStream);
39
40 //------------
41 // decode
42
52 static std::shared_ptr<ImageView> decodeImageView(std::shared_ptr<StreamAccess> inStream);
53
54 //================================================
55 // Array methods
56
63 static void encodeArrayXi8(const ArrayXi8& src, std::shared_ptr<StreamAccess> dst);
64
68 static void encodeArrayXi16(const ArrayXi16& src, std::shared_ptr<StreamAccess> dst);
69
73 static void encodeArrayXi32(const ArrayXi32& src, std::shared_ptr<StreamAccess> dst);
74
78 static void encodeArrayXi64(const ArrayXi64& src, std::shared_ptr<StreamAccess> dst);
79
83 static void encodeArrayXu8(const ArrayXu8& src, std::shared_ptr<StreamAccess> dst);
84
88 static void encodeArrayXu16(const ArrayXu16& src, std::shared_ptr<StreamAccess> dst);
89
93 static void encodeArrayXu32(const ArrayXu32& src, std::shared_ptr<StreamAccess> dst);
94
98 static void encodeArrayXu64(const ArrayXu64& src, std::shared_ptr<StreamAccess> dst);
99
103 static void encodeArrayXf(const ArrayXf& src, std::shared_ptr<StreamAccess> dst);
104
108 static void encodeArrayXd(const ArrayXd& src, std::shared_ptr<StreamAccess> dst);
109
117 static ArrayXi8 decodeArrayXi8(std::shared_ptr<StreamAccess> src);
118
122 static ArrayXi16 decodeArrayXi16(std::shared_ptr<StreamAccess> src);
123
127 static ArrayXi32 decodeArrayXi32(std::shared_ptr<StreamAccess> src);
128
132 static ArrayXi64 decodeArrayXi64(std::shared_ptr<StreamAccess> src);
133
137 static ArrayXu8 decodeArrayXu8(std::shared_ptr<StreamAccess> src);
138
142 static ArrayXu16 decodeArrayXu16(std::shared_ptr<StreamAccess> src);
143
147 static ArrayXu32 decodeArrayXu32(std::shared_ptr<StreamAccess> src);
148
152 static ArrayXu64 decodeArrayXu64(std::shared_ptr<StreamAccess> src);
153
157 static ArrayXf decodeArrayXf(std::shared_ptr<StreamAccess> src);
158
162 static ArrayXd decodeArrayXd(std::shared_ptr<StreamAccess> src);
163
164 //================================================
165 // Vector methods
166
167 // 2D
168 //------------
169 // encode
175 static void encodeVector2u8(const Vector2u8& vect, std::shared_ptr<StreamAccess> outStream);
177 static void encodeVector2u16(const Vector2u16& vect, std::shared_ptr<StreamAccess> outStream);
179 static void encodeVector2u32(const Vector2u32& vect, std::shared_ptr<StreamAccess> outStream);
181 static void encodeVector2u64(const Vector2u64& vect, std::shared_ptr<StreamAccess> outStream);
183 static void encodeVector2i8(const Vector2i8& vect, std::shared_ptr<StreamAccess> outStream);
185 static void encodeVector2i16(const Vector2i16& vect, std::shared_ptr<StreamAccess> outStream);
187 static void encodeVector2i32(const Vector2i32& vect, std::shared_ptr<StreamAccess> outStream);
189 static void encodeVector2i64(const Vector2i64& vect, std::shared_ptr<StreamAccess> outStream);
191 static void encodeVector2f(const Vector2f& vect, std::shared_ptr<StreamAccess> outStream);
193 static void encodeVector2d(const Vector2d& vect, std::shared_ptr<StreamAccess> outStream);
194
195 //------------
196 // decode
197
207 static Vector2u8 decodeVector2u8(std::shared_ptr<StreamAccess> inStream);
209 static Vector2u16 decodeVector2u16(std::shared_ptr<StreamAccess> inStream);
211 static Vector2u32 decodeVector2u32(std::shared_ptr<StreamAccess> inStream);
213 static Vector2u64 decodeVector2u64(std::shared_ptr<StreamAccess> inStream);
215 static Vector2i8 decodeVector2i8(std::shared_ptr<StreamAccess> inStream);
217 static Vector2i16 decodeVector2i16(std::shared_ptr<StreamAccess> inStream);
219 static Vector2i32 decodeVector2i32(std::shared_ptr<StreamAccess> inStream);
221 static Vector2i64 decodeVector2i64(std::shared_ptr<StreamAccess> inStream);
223 static Vector2f decodeVector2f(std::shared_ptr<StreamAccess> inStream);
225 static Vector2d decodeVector2d(std::shared_ptr<StreamAccess> inStream);
226
227 //------------
228 // 3D
229 //------------
230 // encode
231
237 static void encodeVector3u8(const Vector3u8& vect, std::shared_ptr<StreamAccess> outStream);
239 static void encodeVector3u16(const Vector3u16& vect, std::shared_ptr<StreamAccess> outStream);
241 static void encodeVector3u32(const Vector3u32& vect, std::shared_ptr<StreamAccess> outStream);
243 static void encodeVector3u64(const Vector3u64& vect, std::shared_ptr<StreamAccess> outStream);
245 static void encodeVector3i8(const Vector3i8& vect, std::shared_ptr<StreamAccess> outStream);
247 static void encodeVector3i16(const Vector3i16& vect, std::shared_ptr<StreamAccess> outStream);
249 static void encodeVector3i32(const Vector3i32& vect, std::shared_ptr<StreamAccess> outStream);
251 static void encodeVector3i64(const Vector3i64& vect, std::shared_ptr<StreamAccess> outStream);
253 static void encodeVector3f(const Vector3f& vect, std::shared_ptr<StreamAccess> outStream);
255 static void encodeVector3d(const Vector3d& vect, std::shared_ptr<StreamAccess> outStream);
256
257 //-------------
258 // decode
259
269 static Vector3u8 decodeVector3u8(std::shared_ptr<StreamAccess> inStream);
271 static Vector3u16 decodeVector3u16(std::shared_ptr<StreamAccess> inStream);
273 static Vector3u32 decodeVector3u32(std::shared_ptr<StreamAccess> inStream);
275 static Vector3u64 decodeVector3u64(std::shared_ptr<StreamAccess> inStream);
277 static Vector3i8 decodeVector3i8(std::shared_ptr<StreamAccess> inStream);
279 static Vector3i16 decodeVector3i16(std::shared_ptr<StreamAccess> inStream);
281 static Vector3i32 decodeVector3i32(std::shared_ptr<StreamAccess> inStream);
283 static Vector3i64 decodeVector3i64(std::shared_ptr<StreamAccess> inStream);
285 static Vector3f decodeVector3f(std::shared_ptr<StreamAccess> inStream);
287 static Vector3d decodeVector3d(std::shared_ptr<StreamAccess> inStream);
288
289 //------------
290 // 4D
291 //------------
292 // encode
293
299 static void encodeVector4u8(const Vector4u8& vect, std::shared_ptr<StreamAccess> outStream);
301 static void encodeVector4u16(const Vector4u16& vect, std::shared_ptr<StreamAccess> outStream);
303 static void encodeVector4u32(const Vector4u32& vect, std::shared_ptr<StreamAccess> outStream);
305 static void encodeVector4u64(const Vector4u64& vect, std::shared_ptr<StreamAccess> outStream);
307 static void encodeVector4i8(const Vector4i8& vect, std::shared_ptr<StreamAccess> outStream);
309 static void encodeVector4i16(const Vector4i16& vect, std::shared_ptr<StreamAccess> outStream);
311 static void encodeVector4i32(const Vector4i32& vect, std::shared_ptr<StreamAccess> outStream);
313 static void encodeVector4i64(const Vector4i64& vect, std::shared_ptr<StreamAccess> outStream);
315 static void encodeVector4f(const Vector4f& vect, std::shared_ptr<StreamAccess> outStream);
317 static void encodeVector4d(const Vector4d& vect, std::shared_ptr<StreamAccess> outStream);
318
319 //------------
320 // decode
321
331 static Vector4u8 decodeVector4u8(std::shared_ptr<StreamAccess> inStream);
333 static Vector4u16 decodeVector4u16(std::shared_ptr<StreamAccess> inStream);
335 static Vector4u32 decodeVector4u32(std::shared_ptr<StreamAccess> inStream);
337 static Vector4u64 decodeVector4u64(std::shared_ptr<StreamAccess> inStream);
339 static Vector4i8 decodeVector4i8(std::shared_ptr<StreamAccess> inStream);
341 static Vector4i16 decodeVector4i16(std::shared_ptr<StreamAccess> inStream);
343 static Vector4i32 decodeVector4i32(std::shared_ptr<StreamAccess> inStream);
345 static Vector4i64 decodeVector4i64(std::shared_ptr<StreamAccess> inStream);
347 static Vector4f decodeVector4f(std::shared_ptr<StreamAccess> inStream);
349 static Vector4d decodeVector4d(std::shared_ptr<StreamAccess> inStream);
350
351 //================================================
352 // VectorX methods
353 //------------
354 // encode
355
361 static void encodeVectorXu8(const VectorXu8& vect, std::shared_ptr<StreamAccess> inStream);
363 static void encodeVectorXu16(const VectorXu16& vect, std::shared_ptr<StreamAccess> inStream);
365 static void encodeVectorXu32(const VectorXu32& vect, std::shared_ptr<StreamAccess> inStream);
367 static void encodeVectorXu64(const VectorXu64& vect, std::shared_ptr<StreamAccess> inStream);
369 static void encodeVectorXi8(const VectorXi8& vect, std::shared_ptr<StreamAccess> inStream);
371 static void encodeVectorXi16(const VectorXi16& vect, std::shared_ptr<StreamAccess> inStream);
373 static void encodeVectorXi32(const VectorXi32& vect, std::shared_ptr<StreamAccess> inStream);
375 static void encodeVectorXi64(const VectorXi64& vect, std::shared_ptr<StreamAccess> inStream);
377 static void encodeVectorXf(const VectorXf& vect, std::shared_ptr<StreamAccess> inStream);
379 static void encodeVectorXd(const VectorXd& vect, std::shared_ptr<StreamAccess> inStream);
380
381 //------------
382 // decode
383
393 static VectorXu8 decodeVectorXu8(std::shared_ptr<StreamAccess> inStream);
395 static VectorXu16 decodeVectorXu16(std::shared_ptr<StreamAccess> inStream);
397 static VectorXu32 decodeVectorXu32(std::shared_ptr<StreamAccess> inStream);
399 static VectorXu64 decodeVectorXu64(std::shared_ptr<StreamAccess> inStream);
401 static VectorXi8 decodeVectorXi8(std::shared_ptr<StreamAccess> inStream);
403 static VectorXi16 decodeVectorXi16(std::shared_ptr<StreamAccess> inStream);
405 static VectorXi32 decodeVectorXi32(std::shared_ptr<StreamAccess> inStream);
407 static VectorXi64 decodeVectorXi64(std::shared_ptr<StreamAccess> inStream);
409 static VectorXf decodeVectorXf(std::shared_ptr<StreamAccess> inStream);
411 static VectorXd decodeVectorXd(std::shared_ptr<StreamAccess> inStream);
412
413 //================================================
414 // DataFrameView methods
415 //------------
416 // encode
423 static void encodeDataFrameView(std::shared_ptr<DataFrameView> dataFrame, std::shared_ptr<StreamAccess> outStream);
424
425 //------------
426 // decode
427
437 static std::shared_ptr<DataFrameView> decodeDataFrameView(std::shared_ptr<StreamAccess> inStream);
438
439 //================================================
440 // Matrix methods
441 //------------
442 // encode
443
449 static void encodeMatrix3f(const Matrix3f& mat, std::shared_ptr<StreamAccess> outStream);
451 static void encodeMatrix4f(const Matrix4f& mat, std::shared_ptr<StreamAccess> outStream);
453 static void encodeMatrix3d(const Matrix3d& mat, std::shared_ptr<StreamAccess> outStream);
455 static void encodeMatrix4d(const Matrix4d& mat, std::shared_ptr<StreamAccess> outStream);
456
457 //------------
458 // decode
459
469 static Matrix3f decodeMatrix3f(std::shared_ptr<StreamAccess> inStream);
471 static Matrix4f decodeMatrix4f(std::shared_ptr<StreamAccess> inStream);
473 static Matrix3d decodeMatrix3d(std::shared_ptr<StreamAccess> inStream);
475 static Matrix4d decodeMatrix4d(std::shared_ptr<StreamAccess> inStream);
476};
477
478} // namespace iolink