geolib2
serialization.h
Go to the documentation of this file.
1 #ifndef GEOLIB_SERIALIZATION_H_
2 #define GEOLIB_SERIALIZATION_H_
3 
4 #include "datatypes.h"
5 
6 #include <iostream>
7 #include <map>
8 
9 namespace geo {
10 
12 
14 
16 
17 public:
18 
19  static bool serialize(ShapeConstPtr shape, std::ostream& output);
20 
21  static bool serialize(const Shape& shape, std::ostream& output);
22 
23  static ShapePtr deserialize(std::istream& input);
24 
25  static ShapePtr fromFile(const std::string& filename);
26 
27  static void toFile(ShapeConstPtr shape, const std::string& filename);
28 
29  static void toFile(const Shape& shape, const std::string& filename);
30 
31 
32  template<typename T>
33  static void registerDeserializer() {
34  registerDeserializer(T::TYPE, &T::read);
35  }
36 
37 protected:
38 
39  serialization();
40 
41  virtual ~serialization();
42 
44 
45  static void registerDeserializer(const std::string& shape_type, deserialization_method method);
46 
47 };
48 
49 }
50 
51 #endif
geo::ShapePtr
std::shared_ptr< Shape > ShapePtr
Definition: datatypes.h:12
std::string
std::shared_ptr
geo::serialization
Definition: serialization.h:11
geo
Definition: Box.h:6
geo::serialization::deserializers_
static deserializer_map deserializers_
Definition: serialization.h:43
geo::serialization::serialization
serialization()
Definition: serialization.cpp:11
iostream
geo::serialization::fromFile
static ShapePtr fromFile(const std::string &filename)
Definition: serialization.cpp:46
datatypes.h
geo::serialization::deserialization_method
ShapePtr(* deserialization_method)(std::istream &)
Definition: serialization.h:13
geo::serialization::serialize
static bool serialize(ShapeConstPtr shape, std::ostream &output)
Definition: serialization.cpp:18
std::ostream
map
geo::serialization::toFile
static void toFile(ShapeConstPtr shape, const std::string &filename)
Definition: serialization.cpp:54
geo::serialization::deserializer_map
std::map< std::string, deserialization_method > deserializer_map
Definition: serialization.h:15
geo::serialization::deserialize
static ShapePtr deserialize(std::istream &input)
Definition: serialization.cpp:26
geo::serialization::~serialization
virtual ~serialization()
Definition: serialization.cpp:15
std::istream
geo::serialization::registerDeserializer
static void registerDeserializer()
Definition: serialization.h:33
geo::Shape
A geometric description of a shape.
Definition: Shape.h:19