Saving before restoring

release/4.3a0
dellaert 2014-11-30 20:46:47 +01:00
parent 5bcd5d3c89
commit 0dcd102f5e
2 changed files with 127 additions and 140 deletions

View File

@ -152,24 +152,14 @@ void Module::parseMarkup(const std::string& data) {
'<' >> basic.name_p[push_back_a(cls.templateArgs)] >> *(',' >> basic.name_p[push_back_a(cls.templateArgs)]) >> '<' >> basic.name_p[push_back_a(cls.templateArgs)] >> *(',' >> basic.name_p[push_back_a(cls.templateArgs)]) >>
'>'); '>');
// NOTE: allows for pointers to all types // Argument list
// Slightly more permissive than before on basis/eigen type qualification
ArgumentList args; ArgumentList args;
Argument arg0, arg; ArgumentListGrammar argumentlist_g(args);
TypeGrammar argument_type_g(arg.type);
Rule argument_p =
!str_p("const")[assign_a(arg.is_const, true)]
>> argument_type_g
>> (!ch_p('&')[assign_a(arg.is_ref, true)] | !ch_p('*')[assign_a(arg.is_ptr, true)])
[push_back_a(args, arg)]
[assign_a(arg,arg0)];
Rule argumentList_p = !argument_p >> * (',' >> argument_p);
// parse class constructor // parse class constructor
Constructor constructor0(verbose), constructor(verbose); Constructor constructor0(verbose), constructor(verbose);
Rule constructor_p = Rule constructor_p =
(basic.className_p >> '(' >> argumentList_p >> ')' >> ';' >> !basic.comments_p) (basic.className_p >> '(' >> argumentlist_g >> ')' >> ';' >> !basic.comments_p)
[bl::bind(&Constructor::push_back, bl::var(constructor), bl::var(args))] [bl::bind(&Constructor::push_back, bl::var(constructor), bl::var(args))]
[clear_a(args)]; [clear_a(args)];
@ -194,7 +184,7 @@ void Module::parseMarkup(const std::string& data) {
Rule method_p = Rule method_p =
!templateArgValues_p >> !templateArgValues_p >>
(returnValue_p >> methodName_p[assign_a(methodName)] >> (returnValue_p >> methodName_p[assign_a(methodName)] >>
'(' >> argumentList_p >> ')' >> '(' >> argumentlist_g >> ')' >>
!str_p("const")[assign_a(isConst,true)] >> ';' >> *basic.comments_p) !str_p("const")[assign_a(isConst,true)] >> ';' >> *basic.comments_p)
[bl::bind(&Class::addMethod, bl::var(cls), verbose, bl::var(isConst), [bl::bind(&Class::addMethod, bl::var(cls), verbose, bl::var(isConst),
bl::var(methodName), bl::var(args), bl::var(retVal), bl::var(methodName), bl::var(args), bl::var(retVal),
@ -208,7 +198,7 @@ void Module::parseMarkup(const std::string& data) {
Rule static_method_p = Rule static_method_p =
(str_p("static") >> returnValue_p >> staticMethodName_p[assign_a(methodName)] >> (str_p("static") >> returnValue_p >> staticMethodName_p[assign_a(methodName)] >>
'(' >> argumentList_p >> ')' >> ';' >> *basic.comments_p) '(' >> argumentlist_g >> ')' >> ';' >> *basic.comments_p)
[bl::bind(&StaticMethod::addOverload, [bl::bind(&StaticMethod::addOverload,
bl::var(cls.static_methods)[bl::var(methodName)], bl::var(cls.static_methods)[bl::var(methodName)],
bl::var(methodName), bl::var(args), bl::var(retVal), Qualified(),verbose)] bl::var(methodName), bl::var(args), bl::var(retVal), Qualified(),verbose)]
@ -248,7 +238,7 @@ void Module::parseMarkup(const std::string& data) {
Qualified globalFunction; Qualified globalFunction;
Rule global_function_p = Rule global_function_p =
(returnValue_p >> staticMethodName_p[assign_a(globalFunction.name_)] >> (returnValue_p >> staticMethodName_p[assign_a(globalFunction.name_)] >>
'(' >> argumentList_p >> ')' >> ';' >> *basic.comments_p) '(' >> argumentlist_g >> ')' >> ';' >> *basic.comments_p)
[assign_a(globalFunction.namespaces_,namespaces)] [assign_a(globalFunction.namespaces_,namespaces)]
[bl::bind(&GlobalFunction::addOverload, [bl::bind(&GlobalFunction::addOverload,
bl::var(global_functions)[bl::var(globalFunction.name_)], bl::var(global_functions)[bl::var(globalFunction.name_)],
@ -323,8 +313,7 @@ void Module::parseMarkup(const std::string& data) {
printf("parsing stopped at \n%.20s\n",info.stop); printf("parsing stopped at \n%.20s\n",info.stop);
cout << "Stopped near:\n" cout << "Stopped near:\n"
"class '" << cls.name() << "'\n" "class '" << cls.name() << "'\n"
"method '" << methodName << "'\n" "method '" << methodName << endl;
"argument '" << arg.name << "'" << endl;
throw ParseFailed((int)info.length); throw ParseFailed((int)info.length);
} }

View File

@ -1,4 +1,4 @@
// comments! // comments!
class VectorNotEigen; class VectorNotEigen;
class ns::OtherClass; class ns::OtherClass;
@ -7,128 +7,126 @@ namespace gtsam {
class Point2 { class Point2 {
Point2(); Point2();
// Point2(double x, double y); Point2(double x, double y);
double x() const; double x() const;
// double y() const; double y() const;
// int dim() const; int dim() const;
// char returnChar() const; char returnChar() const;
// void argChar(char a) const; void argChar(char a) const;
// void argUChar(unsigned char a) const; void argUChar(unsigned char a) const;
// void eigenArguments(Vector v, Matrix m) const; void eigenArguments(Vector v, Matrix m) const;
// VectorNotEigen vectorConfusion(); VectorNotEigen vectorConfusion();
//
// void serializable() const; // Sets flag and creates export, but does not make serialization functions void serializable() const; // Sets flag and creates export, but does not make serialization functions
}; };
} // end namespace should be removed class Point3 {
Point3(double x, double y, double z);
double norm() const;
//class Point3 { // static functions - use static keyword and uppercase
// Point3(double x, double y, double z); static double staticFunction();
// double norm() const; static gtsam::Point3 StaticFunctionRet(double z);
//
// // static functions - use static keyword and uppercase // enabling serialization functionality
// static double staticFunction(); void serialize() const; // Just triggers a flag internally and removes actual function
// static gtsam::Point3 StaticFunctionRet(double z); };
//
// // enabling serialization functionality }
// void serialize() const; // Just triggers a flag internally and removes actual function // another comment
//};
// // another comment
//}
//// another comment /**
// * A multi-line comment!
//// another comment */
//
///** // An include! Can go anywhere outside of a class, in any order
// * A multi-line comment! #include <folder/path/to/Test.h>
// */
// class Test {
//// An include! Can go anywhere outside of a class, in any order
//#include <folder/path/to/Test.h> /* a comment! */
// // another comment
//class Test { Test();
//
// /* a comment! */ pair<Vector,Matrix> return_pair (Vector v, Matrix A) const; // intentionally the first method
// // another comment
// Test(); bool return_bool (bool value) const; // comment after a line!
// size_t return_size_t (size_t value) const;
// pair<Vector,Matrix> return_pair (Vector v, Matrix A) const; // intentionally the first method int return_int (int value) const;
// double return_double (double value) const;
// bool return_bool (bool value) const; // comment after a line!
// size_t return_size_t (size_t value) const; Test(double a, Matrix b); // a constructor in the middle of a class
// int return_int (int value) const;
// double return_double (double value) const; // comments in the middle!
//
// Test(double a, Matrix b); // a constructor in the middle of a class // (more) comments in the middle!
//
// // comments in the middle! string return_string (string value) const;
// Vector return_vector1(Vector value) const;
// // (more) comments in the middle! Matrix return_matrix1(Matrix value) const;
// Vector return_vector2(Vector value) const;
// string return_string (string value) const; Matrix return_matrix2(Matrix value) const;
// Vector return_vector1(Vector value) const; void arg_EigenConstRef(const Matrix& value) const;
// Matrix return_matrix1(Matrix value) const;
// Vector return_vector2(Vector value) const; bool return_field(const Test& t) const;
// Matrix return_matrix2(Matrix value) const;
// void arg_EigenConstRef(const Matrix& value) const; Test* return_TestPtr(Test* value) const;
// Test return_Test(Test* value) const;
// bool return_field(const Test& t) const;
// gtsam::Point2* return_Point2Ptr(bool value) const;
// Test* return_TestPtr(Test* value) const;
// Test return_Test(Test* value) const; pair<Test*,Test*> create_ptrs () const;
// pair<Test ,Test*> create_MixedPtrs () const;
// gtsam::Point2* return_Point2Ptr(bool value) const; pair<Test*,Test*> return_ptrs (Test* p1, Test* p2) const;
//
// pair<Test*,Test*> create_ptrs () const; void print() const;
// pair<Test ,Test*> create_MixedPtrs () const;
// pair<Test*,Test*> return_ptrs (Test* p1, Test* p2) const; // comments at the end!
//
// void print() const; // even more comments at the end!
// };
// // comments at the end!
//
// // even more comments at the end! Vector aGlobalFunction();
//};
// // An overloaded global function
// Vector overloadedGlobalFunction(int a);
//Vector aGlobalFunction(); Vector overloadedGlobalFunction(int a, double b);
//
//// An overloaded global function // A base class
//Vector overloadedGlobalFunction(int a); virtual class MyBase {
//Vector overloadedGlobalFunction(int a, double b);
// };
//// A base class
//virtual class MyBase { // A templated class
// template<T = {gtsam::Point2, gtsam::Point3}>
//}; virtual class MyTemplate : MyBase {
// MyTemplate();
//// A templated class
//template<T = {gtsam::Point2, gtsam::Point3}> template<ARG = {gtsam::Point2, gtsam::Point3, Vector, Matrix}>
//virtual class MyTemplate : MyBase { void templatedMethod(const ARG& t);
// MyTemplate();
// // Stress test templates and pointer combinations
// template<ARG = {gtsam::Point2, gtsam::Point3, Vector, Matrix}> void accept_T(const T& value) const;
// void templatedMethod(const ARG& t); void accept_Tptr(T* value) const;
// T* return_Tptr(T* value) const;
// // Stress test templates and pointer combinations T return_T(T* value) const;
// void accept_T(const T& value) const; pair<T*,T*> create_ptrs () const;
// void accept_Tptr(T* value) const; pair<T ,T*> create_MixedPtrs () const;
// T* return_Tptr(T* value) const; pair<T*,T*> return_ptrs (T* p1, T* p2) const;
// T return_T(T* value) const; };
// pair<T*,T*> create_ptrs () const;
// pair<T ,T*> create_MixedPtrs () const; // A doubly templated class
// pair<T*,T*> return_ptrs (T* p1, T* p2) const; template<POSE, POINT>
//}; class MyFactor {
// MyFactor(size_t key1, size_t key2, double measured, const gtsam::noiseModel::Base* noiseModel);
//// A doubly templated class };
//template<POSE, POINT>
//class MyFactor { // and a typedef specializing it
// MyFactor(size_t key1, size_t key2, double measured, const gtsam::noiseModel::Base* noiseModel); typedef MyFactor<gtsam::Pose2, Matrix> MyFactorPosePoint2;
//};
// // comments at the end!
//// and a typedef specializing it
//typedef MyFactor<gtsam::Pose2, Matrix> MyFactorPosePoint2; // even more comments at the end!
//
//// comments at the end!
//
//// even more comments at the end!