diff --git a/.cproject b/.cproject index b0eb31888..4649fd973 100644 --- a/.cproject +++ b/.cproject @@ -592,6 +592,7 @@ make + tests/testBayesTree.run true false @@ -599,6 +600,7 @@ make + testBinaryBayesNet.run true false @@ -646,6 +648,7 @@ make + testSymbolicBayesNet.run true false @@ -653,6 +656,7 @@ make + tests/testSymbolicFactor.run true false @@ -660,6 +664,7 @@ make + testSymbolicFactorGraph.run true false @@ -675,6 +680,7 @@ make + tests/testBayesTree true false @@ -1122,6 +1128,7 @@ make + testErrors.run true false @@ -1351,6 +1358,46 @@ true true + + make + -j5 + testBTree.run + true + true + true + + + make + -j5 + testDSF.run + true + true + true + + + make + -j5 + testDSFMap.run + true + true + true + + + make + -j5 + testDSFVector.run + true + true + true + + + make + -j5 + testFixedVector.run + true + true + true + make -j2 @@ -1433,7 +1480,6 @@ make - testSimulated2DOriented.run true false @@ -1473,7 +1519,6 @@ make - testSimulated2D.run true false @@ -1481,7 +1526,6 @@ make - testSimulated3D.run true false @@ -1495,46 +1539,6 @@ true true - - make - -j5 - testBTree.run - true - true - true - - - make - -j5 - testDSF.run - true - true - true - - - make - -j5 - testDSFMap.run - true - true - true - - - make - -j5 - testDSFVector.run - true - true - true - - - make - -j5 - testFixedVector.run - true - true - true - make -j5 @@ -1792,6 +1796,7 @@ cpack + -G DEB true false @@ -1799,6 +1804,7 @@ cpack + -G RPM true false @@ -1806,6 +1812,7 @@ cpack + -G TGZ true false @@ -1813,6 +1820,7 @@ cpack + --config CPackSourceConfig.cmake true false @@ -2417,6 +2425,14 @@ true true + + make + -j4 + testTemplate.run + true + true + true + make -j5 @@ -2651,6 +2667,7 @@ make + testGraph.run true false @@ -2658,6 +2675,7 @@ make + testJunctionTree.run true false @@ -2665,6 +2683,7 @@ make + testSymbolicBayesNetB.run true false @@ -3200,7 +3219,6 @@ make - tests/testGaussianISAM2 true false diff --git a/wrap/Template.h b/wrap/Template.h new file mode 100644 index 000000000..c9edcaf2b --- /dev/null +++ b/wrap/Template.h @@ -0,0 +1,72 @@ +/* ---------------------------------------------------------------------------- + + * GTSAM Copyright 2010, Georgia Tech Research Corporation, + * Atlanta, Georgia 30332-0415 + * All Rights Reserved + * Authors: Frank Dellaert, et al. (see THANKS for the full author list) + + * See LICENSE for the license information + + * -------------------------------------------------------------------------- */ + +/** + * @file Template.h + * @brief Template name + * @author Frank Dellaert + * @date Nov 11, 2014 + **/ + +#pragma once + +#include + +namespace wrap { + +/// The template specification that goes before a method or a class +struct Template { + std::string argName; + std::vector argValues; + void clear() { + argName.clear(); + argValues.clear(); + } +}; + +/* ************************************************************************* */ +// http://boost-spirit.com/distrib/spirit_1_8_2/libs/spirit/doc/grammar.html +struct TemplateGrammar: public classic::grammar { + + Template& result_; ///< successful parse will be placed in here + + TypeListGrammar<'{', '}'> argValues_g; + + /// Construct type grammar and specify where result is placed + TemplateGrammar(Template& result) : + result_(result), argValues_g(result.argValues) { + } + + /// Definition of type grammar + template + struct definition: basic_rules { + + typedef classic::rule Rule; + + Rule templateArgValues_p; + + definition(TemplateGrammar const& self) { + using namespace classic; + templateArgValues_p = (str_p("template") >> '<' + >> (basic_rules::name_p)[assign_a(self.result_.argName)] + >> '=' >> self.argValues_g >> '>'); + } + + Rule const& start() const { + return templateArgValues_p; + } + + }; +}; +// TemplateGrammar + +}// \namespace wrap + diff --git a/wrap/tests/testTemplate.cpp b/wrap/tests/testTemplate.cpp new file mode 100644 index 000000000..b1f3ce544 --- /dev/null +++ b/wrap/tests/testTemplate.cpp @@ -0,0 +1,56 @@ +/* ---------------------------------------------------------------------------- + + * GTSAM Copyright 2010, Georgia Tech Research Corporation, + * Atlanta, Georgia 30332-0415 + * All Rights Reserved + * Authors: Frank Dellaert, et al. (see THANKS for the full author list) + + * See LICENSE for the license information + + * -------------------------------------------------------------------------- */ + +/** + * @file testTemplate.cpp + * @brief unit test for Template class + * @author Frank Dellaert + * @date Dec 1, 2014 + **/ + +#include +#include + +using namespace std; +using namespace wrap; + +//****************************************************************************** +TEST( Template, grammar ) { + + using classic::space_p; + + // Create type grammar that will place result in actual + Template actual; + TemplateGrammar g(actual); + + EXPECT(parse("template", g, space_p).full); + EXPECT_LONGS_EQUAL(2, actual.argValues.size()); + EXPECT(actual.argName=="T"); + EXPECT(actual.argValues[0]==Qualified("gtsam","Point2",Qualified::CLASS)); + EXPECT(actual.argValues[1]==Qualified("Matrix",Qualified::EIGEN)); + actual.clear(); + + EXPECT(parse("template", g, space_p).full); + EXPECT_LONGS_EQUAL(4, actual.argValues.size()); + EXPECT(actual.argName=="ARG"); + EXPECT(actual.argValues[0]==Qualified("gtsam","Point2",Qualified::CLASS)); + EXPECT(actual.argValues[1]==Qualified("gtsam","Point3",Qualified::CLASS)); + EXPECT(actual.argValues[2]==Qualified("Vector",Qualified::EIGEN)); + EXPECT(actual.argValues[3]==Qualified("Matrix",Qualified::EIGEN)); + actual.clear(); +} + +//****************************************************************************** +int main() { + TestResult tr; + return TestRegistry::runAllTests(tr); +} +//******************************************************************************