Pothos
0.7.0-gf7fbae99
The Pothos dataflow programming software suite
include
Pothos
Archive
Polymorphic.hpp
Go to the documentation of this file.
1
11
#pragma once
12
#include <
Pothos/Config.hpp
>
13
#include <
Pothos/Archive/ArchiveEntry.hpp
>
14
#include <
Pothos/Archive/Numbers.hpp
>
15
#include <
Pothos/Archive/Invoke.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
{
45
Pothos::serialization::invokeSplit
(ar, t, ver);
46
}
47
48
}}
Config.hpp
Pothos
Definition:
ArchiveEntry.hpp:20
Pothos::serialization::invokeSplit
std::enable_if< Archive::isSave::value >::type invokeSplit(Archive &ar, T &value, const unsigned int ver)
Definition:
Invoke.hpp:69
Numbers.hpp
Pothos::serialization::save
void save(Archive &ar, const std::complex< T > &t, const unsigned int)
Definition:
Complex.hpp:20
Pothos::serialization::serialize
void serialize(Archive &ar, std::complex< T > &t, const unsigned int ver)
Definition:
Complex.hpp:37
Pothos::Archive::ArchiveEntry::find
static const ArchiveEntry & find(const std::type_info &type)
Lookup the entry given the type info or throw if not found.
ArchiveEntry.hpp
Invoke.hpp
Pothos::serialization::load
void load(Archive &ar, std::complex< T > &t, const unsigned int)
Definition:
Complex.hpp:27
Generated on Tue Apr 10 2018 20:23:41 for Pothos by
1.8.13