Serialization.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: Serialization.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: Abstract base class for any serializable class.
6 > Created Time: 2017/04/28
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_SERIALIZATION_H
10 #define CUBBYFLOW_SERIALIZATION_H
11 
12 #include <Core/Array/Array1.h>
13 
14 #include <vector>
15 #include <cstring>
16 
17 namespace CubbyFlow
18 {
21  {
22  public:
24  virtual void Serialize(std::vector<uint8_t>* buffer) const = 0;
25 
27  virtual void Deserialize(const std::vector<uint8_t>& buffer) = 0;
28  };
29 
31  void Serialize(const Serializable* serializable, std::vector<uint8_t>* buffer);
32 
34  void Serialize(const uint8_t* data, size_t size, std::vector<uint8_t>* buffer);
35 
37  template <typename T>
38  void Serialize(const ConstArrayAccessor1<T>& array, std::vector<uint8_t>* buffer);
39 
41  void Deserialize(const std::vector<uint8_t>& buffer, Serializable* serializable);
42 
44  void Deserialize(const std::vector<uint8_t>& buffer, std::vector<uint8_t>* data);
45 
47  template <typename T>
48  void Deserialize(const std::vector<uint8_t>& buffer, Array1<T>* array);
49 }
50 
52 
53 #endif
Abstract base class for any serializable class.
Definition: Serialization.h:20
virtual void Deserialize(const std::vector< uint8_t > &buffer)=0
Deserializes this instance from the flat buffer.
1-D read-only array accessor class.
Definition: ArrayAccessor1.h:185
1-D array class.
Definition: Array1.h:29
Definition: pybind11Utils.h:24
void Deserialize(const std::vector< uint8_t > &buffer, Array1< T > *array)
Deserializes buffer to data chunk using common schema.
Definition: Serialization-Impl.h:22
void Serialize(const ConstArrayAccessor1< T > &array, std::vector< uint8_t > *buffer)
Serializes data chunk using common schema.
Definition: Serialization-Impl.h:15
virtual void Serialize(std::vector< uint8_t > *buffer) const =0
Serializes this instance into the flat buffer.