Newer
Older
#ifndef LIB4NEURO_EXPRTKWRAPPERSERIALIZATION_H
#define LIB4NEURO_EXPRTKWRAPPERSERIALIZATION_H
Martin Beseda
committed
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/export.hpp>
Martin Beseda
committed
#include <boost/serialization/serialization.hpp>
Martin Beseda
committed
//TODO check different order of headers - possible bug
#include "ExprtkWrapper.h"
#include "exprtk.hpp"
Martin Beseda
committed
//BOOST_CLASS_EXPORT_KEY(ExprtkWrapper);
Martin Beseda
committed
/**
* Class implementing the private properties
* of ExprtkWrapper class.
*/
Martin Beseda
committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//class ExprtkWrapper::ExprtkWrapperImpl {
//
//public:
//
// /**
// * Struct used to access private properties from
// * the serialization function
// */
// struct access;
//
// /**
// *
// */
// expression_t* expression = nullptr;
//
// /**
// *
// */
// symbol_table_t* symbol_table = nullptr;
//
// /**
// *
// */
// parser_t* parser = nullptr;
//
// /**
// * variables
// */
// double x, y, z, t, f;
//
// /**
// * referential expression string
// */
// std::string expression_str;
//};
Martin Beseda
committed
struct ExprtkWrapper::access {
template<class Archive>
static void serialize(Archive& ar,
Martin Beseda
committed
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
ExprtkWrapper& w,
const unsigned int version) {}
template<class Archive>
static void save_construct_data(Archive & ar,
const ExprtkWrapper* w,
const unsigned long int file_version){
ar << w->expression_str;
ar << w->x;
ar << w->y;
ar << w->z;
ar << w->t;
ar << w->f;
}
template<class Archive>
static void load_construct_data(Archive & ar,
ExprtkWrapper* w,
const unsigned long int file_version) {
expression_t* expression;
symbol_table_t* symbol_table;
parser_t* parser;
double x, y, z, t, f;
std::string expression_str;
ar >> expression_str;
ar >> x;
ar >> y;
ar >> z;
ar >> t;
ar >> f;
::new(w)ExprtkWrapper(expression,
symbol_table,
parser,
x,
y,
z,
t,
f,
expression_str);
Martin Beseda
committed
}
};
Martin Beseda
committed
namespace boost::serialization {
template<class Archive>
inline void load_construct_data(Archive & ar,
ExprtkWrapper* w,
const unsigned long int file_version) {
ExprtkWrapper::access::load_construct_data(ar, w, file_version);
}
Martin Beseda
committed
Martin Beseda
committed
template<class Archive>
inline void save_construct_data(Archive & ar,
const ExprtkWrapper* w,
const unsigned long int file_version) {
ExprtkWrapper::access::save_construct_data(ar, w, file_version);
}
Martin Beseda
committed
Martin Beseda
committed
/**
* Serialization function
* @tparam Archive Boost library template
* @param ar Boost parameter - filled automatically during serialization!
* @param n ExprtkWrapper instance
* @param version Boost parameter - filled automatically during serialization!
*/
template<class Archive>
void serialize(Archive& ar,
ExprtkWrapper& n,
const unsigned int version) {}
} // namespace boost::serialization
Martin Beseda
committed
#endif //LIB4NEURO_EXPRTKWRAPPERSERIALIZATION_H