Add serialization functions that call base classes, to avoid "unregistered void cast" errors (in MATLAB, as flagged by issue #398), as mentioned in http://tb-nguyen.blogspot.com/2009/08/more-on-using-boost-serialization-and.html

release/4.3a0
Frank Dellaert 2018-12-30 18:37:38 -05:00
parent 63acd1a50c
commit 3b3e393817
4 changed files with 31 additions and 0 deletions

View File

@ -266,6 +266,13 @@ class ExpressionFactor2 : public ExpressionFactor<T> {
virtual Expression<T> expression() const { virtual Expression<T> expression() const {
return expression(this->keys_[0], this->keys_[1]); return expression(this->keys_[0], this->keys_[1]);
} }
friend class boost::serialization::access;
template <class ARCHIVE>
void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
ar& boost::serialization::make_nvp(
"ExpressionFactor", boost::serialization::base_object<ExpressionFactor<T> >(*this));
}
}; };
// ExpressionFactor2 // ExpressionFactor2

View File

@ -60,6 +60,14 @@ struct BearingFactor : public ExpressionFactor2<T, A1, A2> {
std::cout << s << "BearingFactor" << std::endl; std::cout << s << "BearingFactor" << std::endl;
Base::print(s, kf); Base::print(s, kf);
} }
private:
friend class boost::serialization::access;
template <class ARCHIVE>
void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
ar& boost::serialization::make_nvp(
"Base", boost::serialization::base_object<Base>(*this));
}
}; // BearingFactor }; // BearingFactor
/// traits /// traits

View File

@ -73,6 +73,14 @@ class BearingRangeFactor
Base::print(s, kf); Base::print(s, kf);
} }
private:
friend class boost::serialization::access;
template <class ARCHIVE>
void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
ar& boost::serialization::make_nvp(
"Base", boost::serialization::base_object<Base>(*this));
}
}; // BearingRangeFactor }; // BearingRangeFactor
/// traits /// traits

View File

@ -65,6 +65,14 @@ class RangeFactor : public ExpressionFactor2<T, A1, A2> {
std::cout << s << "RangeFactor" << std::endl; std::cout << s << "RangeFactor" << std::endl;
Base::print(s, kf); Base::print(s, kf);
} }
private:
friend class boost::serialization::access;
template <class ARCHIVE>
void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
ar& boost::serialization::make_nvp(
"Base", boost::serialization::base_object<Base>(*this));
}
}; // \ RangeFactor }; // \ RangeFactor
/// traits /// traits