Pothos  0.7.0-gf7fbae99
The Pothos dataflow programming software suite
Polymorphic.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 #include <Pothos/Config.hpp>
16 #include <type_traits>
17 
18 namespace Pothos {
19 namespace serialization {
20 
21 template <typename Archive, typename T>
22 typename std::enable_if<std::is_polymorphic<T>::value>::type
23 save(Archive &ar, const T* const &t, const unsigned int)
24 {
25  const auto &entry = Pothos::Archive::ArchiveEntry::find(typeid(*t));
26  ar << entry.getHash();
27  entry.save(ar, t);
28 }
29 
30 template <typename Archive, typename T>
31 typename std::enable_if<std::is_polymorphic<T>::value>::type
32 load(Archive &ar, T* &t, const unsigned int)
33 {
34  unsigned long long idHash;
35  ar >> idHash;
36  const auto &entry = Pothos::Archive::ArchiveEntry::find(idHash);
37  delete t; //delete previous pointer or its null
38  t = static_cast<T*>(entry.load(ar));
39 }
40 
41 template <typename Archive, typename T>
42 typename std::enable_if<std::is_polymorphic<T>::value>::type
43 serialize(Archive &ar, T* &t, const unsigned int ver)
44 {
46 }
47 
48 }}
Definition: ArchiveEntry.hpp:20
std::enable_if< Archive::isSave::value >::type invokeSplit(Archive &ar, T &value, const unsigned int ver)
Definition: Invoke.hpp:69
void save(Archive &ar, const std::complex< T > &t, const unsigned int)
Definition: Complex.hpp:20
void serialize(Archive &ar, std::complex< T > &t, const unsigned int ver)
Definition: Complex.hpp:37
static const ArchiveEntry & find(const std::type_info &type)
Lookup the entry given the type info or throw if not found.
void load(Archive &ar, std::complex< T > &t, const unsigned int)
Definition: Complex.hpp:27