IOLink  IOL_v1.2.0_release
Serialization.h
1 #pragma once
2 
3 #include <memory>
4 
5 #include <iolink/Vector.h>
6 #include <iolink/VectorX.h>
7 #include <iolink/storage/StreamAccess.h>
8 #include <iolink/view/ImageView.h>
9 
10 namespace iolink
11 {
12 
17 class IOLINK_API Serialization
18 {
19 public:
20  Serialization() = delete;
21  Serialization(const Serialization& other) = delete; // copy constructor
22  Serialization(Serialization&& other) = delete; // move constructor
23  Serialization& operator=(const Serialization& other) = delete; // copy assignment
24  Serialization& operator=(Serialization&& other) = delete; // move assignment
25 
26  //================================================
27  // ImageView methods
28 
29  // encode
36  static void encodeImageView(std::shared_ptr<ImageView> image, std::shared_ptr<StreamAccess> outStream);
37 
38  //------------
39  // decode
40 
50  static std::shared_ptr<ImageView> decodeImageView(std::shared_ptr<StreamAccess> inStream);
51 
52  //================================================
53  // Vector methods
54 
55  // 2D
56  //------------
57  // encode
63  static void encodeVector2u8(const Vector2u8& vect, std::shared_ptr<StreamAccess> outStream);
65  static void encodeVector2u16(const Vector2u16& vect, std::shared_ptr<StreamAccess> outStream);
67  static void encodeVector2u32(const Vector2u32& vect, std::shared_ptr<StreamAccess> outStream);
69  static void encodeVector2u64(const Vector2u64& vect, std::shared_ptr<StreamAccess> outStream);
71  static void encodeVector2i8(const Vector2i8& vect, std::shared_ptr<StreamAccess> outStream);
73  static void encodeVector2i16(const Vector2i16& vect, std::shared_ptr<StreamAccess> outStream);
75  static void encodeVector2i32(const Vector2i32& vect, std::shared_ptr<StreamAccess> outStream);
77  static void encodeVector2i64(const Vector2i64& vect, std::shared_ptr<StreamAccess> outStream);
79  static void encodeVector2f(const Vector2f& vect, std::shared_ptr<StreamAccess> outStream);
81  static void encodeVector2d(const Vector2d& vect, std::shared_ptr<StreamAccess> outStream);
82 
83  //------------
84  // decode
85 
95  static Vector2u8 decodeVector2u8(std::shared_ptr<StreamAccess> inStream);
97  static Vector2u16 decodeVector2u16(std::shared_ptr<StreamAccess> inStream);
99  static Vector2u32 decodeVector2u32(std::shared_ptr<StreamAccess> inStream);
101  static Vector2u64 decodeVector2u64(std::shared_ptr<StreamAccess> inStream);
103  static Vector2i8 decodeVector2i8(std::shared_ptr<StreamAccess> inStream);
105  static Vector2i16 decodeVector2i16(std::shared_ptr<StreamAccess> inStream);
107  static Vector2i32 decodeVector2i32(std::shared_ptr<StreamAccess> inStream);
109  static Vector2i64 decodeVector2i64(std::shared_ptr<StreamAccess> inStream);
111  static Vector2f decodeVector2f(std::shared_ptr<StreamAccess> inStream);
113  static Vector2d decodeVector2d(std::shared_ptr<StreamAccess> inStream);
114 
115  //------------
116  // 3D
117  //------------
118  // encode
119 
125  static void encodeVector3u8(const Vector3u8& vect, std::shared_ptr<StreamAccess> outStream);
127  static void encodeVector3u16(const Vector3u16& vect, std::shared_ptr<StreamAccess> outStream);
129  static void encodeVector3u32(const Vector3u32& vect, std::shared_ptr<StreamAccess> outStream);
131  static void encodeVector3u64(const Vector3u64& vect, std::shared_ptr<StreamAccess> outStream);
133  static void encodeVector3i8(const Vector3i8& vect, std::shared_ptr<StreamAccess> outStream);
135  static void encodeVector3i16(const Vector3i16& vect, std::shared_ptr<StreamAccess> outStream);
137  static void encodeVector3i32(const Vector3i32& vect, std::shared_ptr<StreamAccess> outStream);
139  static void encodeVector3i64(const Vector3i64& vect, std::shared_ptr<StreamAccess> outStream);
141  static void encodeVector3f(const Vector3f& vect, std::shared_ptr<StreamAccess> outStream);
143  static void encodeVector3d(const Vector3d& vect, std::shared_ptr<StreamAccess> outStream);
144 
145  //-------------
146  // decode
147 
157  static Vector3u8 decodeVector3u8(std::shared_ptr<StreamAccess> inStream);
159  static Vector3u16 decodeVector3u16(std::shared_ptr<StreamAccess> inStream);
161  static Vector3u32 decodeVector3u32(std::shared_ptr<StreamAccess> inStream);
163  static Vector3u64 decodeVector3u64(std::shared_ptr<StreamAccess> inStream);
165  static Vector3i8 decodeVector3i8(std::shared_ptr<StreamAccess> inStream);
167  static Vector3i16 decodeVector3i16(std::shared_ptr<StreamAccess> inStream);
169  static Vector3i32 decodeVector3i32(std::shared_ptr<StreamAccess> inStream);
171  static Vector3i64 decodeVector3i64(std::shared_ptr<StreamAccess> inStream);
173  static Vector3f decodeVector3f(std::shared_ptr<StreamAccess> inStream);
175  static Vector3d decodeVector3d(std::shared_ptr<StreamAccess> inStream);
176 
177  //------------
178  // 4D
179  //------------
180  // encode
181 
187  static void encodeVector4u8(const Vector4u8& vect, std::shared_ptr<StreamAccess> outStream);
189  static void encodeVector4u16(const Vector4u16& vect, std::shared_ptr<StreamAccess> outStream);
191  static void encodeVector4u32(const Vector4u32& vect, std::shared_ptr<StreamAccess> outStream);
193  static void encodeVector4u64(const Vector4u64& vect, std::shared_ptr<StreamAccess> outStream);
195  static void encodeVector4i8(const Vector4i8& vect, std::shared_ptr<StreamAccess> outStream);
197  static void encodeVector4i16(const Vector4i16& vect, std::shared_ptr<StreamAccess> outStream);
199  static void encodeVector4i32(const Vector4i32& vect, std::shared_ptr<StreamAccess> outStream);
201  static void encodeVector4i64(const Vector4i64& vect, std::shared_ptr<StreamAccess> outStream);
203  static void encodeVector4f(const Vector4f& vect, std::shared_ptr<StreamAccess> outStream);
205  static void encodeVector4d(const Vector4d& vect, std::shared_ptr<StreamAccess> outStream);
206 
207  //------------
208  // decode
209 
219  static Vector4u8 decodeVector4u8(std::shared_ptr<StreamAccess> inStream);
221  static Vector4u16 decodeVector4u16(std::shared_ptr<StreamAccess> inStream);
223  static Vector4u32 decodeVector4u32(std::shared_ptr<StreamAccess> inStream);
225  static Vector4u64 decodeVector4u64(std::shared_ptr<StreamAccess> inStream);
227  static Vector4i8 decodeVector4i8(std::shared_ptr<StreamAccess> inStream);
229  static Vector4i16 decodeVector4i16(std::shared_ptr<StreamAccess> inStream);
231  static Vector4i32 decodeVector4i32(std::shared_ptr<StreamAccess> inStream);
233  static Vector4i64 decodeVector4i64(std::shared_ptr<StreamAccess> inStream);
235  static Vector4f decodeVector4f(std::shared_ptr<StreamAccess> inStream);
237  static Vector4d decodeVector4d(std::shared_ptr<StreamAccess> inStream);
238 
239  //================================================
240  // VectorX methods
241  //------------
242  // encode
243 
249  static void encodeVectorXu8(const VectorXu8& vect, std::shared_ptr<StreamAccess> inStream);
251  static void encodeVectorXu16(const VectorXu16& vect, std::shared_ptr<StreamAccess> inStream);
253  static void encodeVectorXu32(const VectorXu32& vect, std::shared_ptr<StreamAccess> inStream);
255  static void encodeVectorXu64(const VectorXu64& vect, std::shared_ptr<StreamAccess> inStream);
257  static void encodeVectorXi8(const VectorXi8& vect, std::shared_ptr<StreamAccess> inStream);
259  static void encodeVectorXi16(const VectorXi16& vect, std::shared_ptr<StreamAccess> inStream);
261  static void encodeVectorXi32(const VectorXi32& vect, std::shared_ptr<StreamAccess> inStream);
263  static void encodeVectorXi64(const VectorXi64& vect, std::shared_ptr<StreamAccess> inStream);
265  static void encodeVectorXf(const VectorXf& vect, std::shared_ptr<StreamAccess> inStream);
267  static void encodeVectorXd(const VectorXd& vect, std::shared_ptr<StreamAccess> inStream);
268 
269  //------------
270  // decode
271 
281  static VectorXu8 decodeVectorXu8(std::shared_ptr<StreamAccess> inStream);
283  static VectorXu16 decodeVectorXu16(std::shared_ptr<StreamAccess> inStream);
285  static VectorXu32 decodeVectorXu32(std::shared_ptr<StreamAccess> inStream);
287  static VectorXu64 decodeVectorXu64(std::shared_ptr<StreamAccess> inStream);
289  static VectorXi8 decodeVectorXi8(std::shared_ptr<StreamAccess> inStream);
291  static VectorXi16 decodeVectorXi16(std::shared_ptr<StreamAccess> inStream);
293  static VectorXi32 decodeVectorXi32(std::shared_ptr<StreamAccess> inStream);
295  static VectorXi64 decodeVectorXi64(std::shared_ptr<StreamAccess> inStream);
297  static VectorXf decodeVectorXf(std::shared_ptr<StreamAccess> inStream);
299  static VectorXd decodeVectorXd(std::shared_ptr<StreamAccess> inStream);
300 };
301 
302 } // namespace iolink