Pothos  0.2.1-g9f04573d
The Pothos dataflow programming software suite
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
Serialize.hpp
Go to the documentation of this file.
1 
15 #pragma once
16 
21 #define POTHOS_OBJECT_SERIALIZE(ValueType) \
22  POTHOS_CLASS_EXPORT_GUID(Pothos::Detail::ObjectContainerT<ValueType>, "Pothos::Object<" #ValueType ">")
23 
24 #include <Pothos/Config.hpp>
26 #include <cassert>
27 
28 //disable auto linking
29 #ifndef POTHOS_ALL_NO_LIB
30 #define POTHOS_ALL_NO_LIB
31 #endif
32 
33 #include <Pothos/serialization/base_object.hpp>
34 #include <Pothos/serialization/split_free.hpp>
35 
36 #include <Pothos/archive/polymorphic_iarchive.hpp>
37 #include <Pothos/archive/polymorphic_oarchive.hpp>
38 
39 #include <Pothos/serialization/export.hpp>
40 #include <Pothos/serialization/extended_type_info.hpp>
41 
42 namespace Pothos {
43 namespace serialization {
44 
45 template<class Archive>
46 void serialize(Archive &, Pothos::Detail::ObjectContainer &, const unsigned int){}
47 
48 template <class Archive, typename ValueType>
49 void serialize(Archive &ar, Pothos::Detail::ObjectContainerT<ValueType> &t, const unsigned int)
50 {
51  Pothos::serialization::base_object<Pothos::Detail::ObjectContainer>(t);
52  ar & t.value;
53 }
54 
55 template<class Archive>
56 void save(Archive & ar, const Pothos::Object &t, const unsigned int)
57 {
58  const bool is_null = not t;
59  ar << is_null;
60  if (not is_null) ar << t._impl;
61 }
62 
63 template<class Archive>
64 void load(Archive & ar, Pothos::Object &t, const unsigned int)
65 {
66  assert(not t);
67  bool is_null = false;
68  ar >> is_null;
69  if (not is_null) ar >> t._impl;
70 }
71 
72 } // namespace serialization
73 } // namespace Pothos
74 
75 POTHOS_SERIALIZATION_SPLIT_FREE(Pothos::Object)
76 
77 #include <Pothos/serialization/complex.hpp>
78 #include <Pothos/serialization/string.hpp>
79 #include <Pothos/serialization/vector.hpp>
80 #include <Pothos/serialization/set.hpp>
81 #include <Pothos/serialization/map.hpp>
void save(Archive &ar, const Pothos::Object &t, const unsigned int)
Definition: Serialize.hpp:56
void load(Archive &ar, Pothos::Object &t, const unsigned int)
Definition: Serialize.hpp:64
Detail::ObjectContainer * _impl
Private implementation details.
Definition: Object.hpp:258
Definition: Object.hpp:55
void serialize(Archive &, Pothos::Detail::ObjectContainer &, const unsigned int)
Definition: Serialize.hpp:46