Commit ccf4041d authored by Pierre Fernbach's avatar Pierre Fernbach Committed by Guilhem Saurel
Browse files

Move call to register_type from archive to curve_abc::serialize()

parent 5d9dcae1
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
#include "MathDefs.h" #include "MathDefs.h"
#include "serialization/archive.hpp" #include "serialization/archive.hpp"
#include "serialization/eigen-matrix.hpp" #include "serialization/eigen-matrix.hpp"
#include "serialization/registeration.hpp"
#include <boost/serialization/shared_ptr.hpp> #include <boost/serialization/shared_ptr.hpp>
#include <boost/smart_ptr/shared_ptr.hpp> #include <boost/smart_ptr/shared_ptr.hpp>
#include <functional> #include <functional>
namespace curves { namespace curves {
...@@ -136,7 +136,8 @@ struct curve_abc : std::unary_function<Time, Point>, public serialization::Seria ...@@ -136,7 +136,8 @@ struct curve_abc : std::unary_function<Time, Point>, public serialization::Seria
// Serialization of the class // Serialization of the class
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& /*ar*/, const unsigned int version) { void serialize(Archive& ar, const unsigned int version) {
serialization::register_types<Archive>(ar);
if (version) { if (version) {
// Do something depending on version ? // Do something depending on version ?
} }
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <boost/archive/binary_iarchive.hpp> #include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp> #include <boost/archive/binary_oarchive.hpp>
#include <boost/serialization/version.hpp> #include <boost/serialization/version.hpp>
#include "registeration.hpp"
/* Define the current version number for the serialization /* Define the current version number for the serialization
* Must be increased everytime the save() method of a class is modified * Must be increased everytime the save() method of a class is modified
...@@ -55,7 +54,6 @@ struct Serializable { ...@@ -55,7 +54,6 @@ struct Serializable {
std::ifstream ifs(filename.c_str()); std::ifstream ifs(filename.c_str());
if (ifs) { if (ifs) {
boost::archive::text_iarchive ia(ifs); boost::archive::text_iarchive ia(ifs);
register_types<boost::archive::text_iarchive>(ia);
ia >> derived<Derived>(); ia >> derived<Derived>();
} else { } else {
const std::string exception_message(filename + " does not seem to be a valid file."); const std::string exception_message(filename + " does not seem to be a valid file.");
...@@ -69,7 +67,6 @@ struct Serializable { ...@@ -69,7 +67,6 @@ struct Serializable {
std::ofstream ofs(filename.c_str()); std::ofstream ofs(filename.c_str());
if (ofs) { if (ofs) {
boost::archive::text_oarchive oa(ofs); boost::archive::text_oarchive oa(ofs);
register_types<boost::archive::text_oarchive>(oa);
oa << derived<Derived>(); oa << derived<Derived>();
} else { } else {
const std::string exception_message(filename + " does not seem to be a valid file."); const std::string exception_message(filename + " does not seem to be a valid file.");
...@@ -86,7 +83,6 @@ struct Serializable { ...@@ -86,7 +83,6 @@ struct Serializable {
std::ifstream ifs(filename.c_str()); std::ifstream ifs(filename.c_str());
if (ifs) { if (ifs) {
boost::archive::xml_iarchive ia(ifs); boost::archive::xml_iarchive ia(ifs);
register_types<boost::archive::xml_iarchive>(ia);
ia >> boost::serialization::make_nvp(tag_name.c_str(), derived<Derived>()); ia >> boost::serialization::make_nvp(tag_name.c_str(), derived<Derived>());
} else { } else {
const std::string exception_message(filename + " does not seem to be a valid file."); const std::string exception_message(filename + " does not seem to be a valid file.");
...@@ -103,7 +99,6 @@ struct Serializable { ...@@ -103,7 +99,6 @@ struct Serializable {
std::ofstream ofs(filename.c_str()); std::ofstream ofs(filename.c_str());
if (ofs) { if (ofs) {
boost::archive::xml_oarchive oa(ofs); boost::archive::xml_oarchive oa(ofs);
register_types<boost::archive::xml_oarchive>(oa);
oa << boost::serialization::make_nvp(tag_name.c_str(), derived<Derived>()); oa << boost::serialization::make_nvp(tag_name.c_str(), derived<Derived>());
} else { } else {
const std::string exception_message(filename + " does not seem to be a valid file."); const std::string exception_message(filename + " does not seem to be a valid file.");
...@@ -117,7 +112,6 @@ struct Serializable { ...@@ -117,7 +112,6 @@ struct Serializable {
std::ifstream ifs(filename.c_str()); std::ifstream ifs(filename.c_str());
if (ifs) { if (ifs) {
boost::archive::binary_iarchive ia(ifs); boost::archive::binary_iarchive ia(ifs);
register_types<boost::archive::binary_iarchive>(ia);
ia >> derived<Derived>(); ia >> derived<Derived>();
} else { } else {
const std::string exception_message(filename + " does not seem to be a valid file."); const std::string exception_message(filename + " does not seem to be a valid file.");
...@@ -131,7 +125,6 @@ struct Serializable { ...@@ -131,7 +125,6 @@ struct Serializable {
std::ofstream ofs(filename.c_str()); std::ofstream ofs(filename.c_str());
if (ofs) { if (ofs) {
boost::archive::binary_oarchive oa(ofs); boost::archive::binary_oarchive oa(ofs);
register_types<boost::archive::binary_oarchive>(oa);
oa << derived<Derived>(); oa << derived<Derived>();
} else { } else {
const std::string exception_message(filename + " does not seem to be a valid file."); const std::string exception_message(filename + " does not seem to be a valid file.");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment