Added export flags, Values now serializes

release/4.3a0
Alex Cunningham 2013-06-19 17:50:03 +00:00
parent 4d76386aa7
commit f1b1a2f7d2
4 changed files with 24 additions and 1 deletions

View File

@ -530,4 +530,10 @@ void Class::deserialization_fragments(FileWriter& proxyFile, FileWriter& wrapper
proxyFile.oss << " end\n";
proxyFile.oss << " end\n\n";
}
/* ************************************************************************* */
std::string Class::getSerializationExport() const {
//BOOST_CLASS_EXPORT_GUID(gtsam::SharedDiagonal, "gtsamSharedDiagonal");
return "BOOST_CLASS_EXPORT_GUID(" + qualifiedName("::") + ", \"" + qualifiedName() + "\");";
}
/* ************************************************************************* */

View File

@ -66,6 +66,9 @@ struct Class {
// The typedef line for this class, if this class is a typedef, otherwise returns an empty string.
std::string getTypedef() const;
// Returns the string for an export flag
std::string getSerializationExport() const;
// Creates a member function that performs serialization
void serialization_fragments(FileWriter& proxyFile, FileWriter& wrapperFile,
const std::string& wrapperName, std::vector<std::string>& functionNames) const;

View File

@ -492,11 +492,14 @@ void Module::matlab_code(const string& toolboxPath, const string& headerPath) co
wrapperFile.oss << "#include <boost/foreach.hpp>\n";
wrapperFile.oss << "\n";
// Generate includes while avoiding redundant includes
// Include boost.serialization archive headers before other class headers
if (hasSerialiable) {
wrapperFile.oss << "#include <boost/serialization/export.hpp>\n";
wrapperFile.oss << "#include <boost/archive/text_iarchive.hpp>\n";
wrapperFile.oss << "#include <boost/archive/text_oarchive.hpp>\n\n";
}
// Generate includes while avoiding redundant includes
generateIncludes(wrapperFile);
// create typedef classes - we put this at the top of the wrap file so that collectors and method arguments can use these typedefs
@ -506,6 +509,15 @@ void Module::matlab_code(const string& toolboxPath, const string& headerPath) co
}
wrapperFile.oss << "\n";
// Generate boost.serialization export flags (needs typedefs from above)
if (hasSerialiable) {
BOOST_FOREACH(const Class& cls, expandedClasses) {
if(cls.isSerializable)
wrapperFile.oss << cls.getSerializationExport() << "\n";
}
wrapperFile.oss << "\n";
}
// Generate collectors and cleanup function to be called from mexAtExit
WriteCollectorsAndCleanupFcn(wrapperFile, name, expandedClasses);

View File

@ -2,11 +2,13 @@
#include <map>
#include <boost/foreach.hpp>
#include <boost/serialization/export.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <folder/path/to/Test.h>
BOOST_CLASS_EXPORT_GUID(Point3, "Point3");
typedef std::set<boost::shared_ptr<Point2>*> Collector_Point2;
static Collector_Point2 collector_Point2;