From 59551679863720dcf44af7124dc5ec0d1dae78b5 Mon Sep 17 00:00:00 2001
From: Joan Sola <jsola@iri.upc.edu>
Date: Fri, 8 Apr 2016 10:02:26 +0200
Subject: [PATCH] Wrapp functions() inside namespace wolf{}, and add using
 namespace wolf; inside main()

---
 src/examples/test_analytic_odom_constraint.cpp |  4 ++++
 src/examples/test_autodiff.cpp                 |  4 ++++
 src/examples/test_capture_laser_2D.cpp         |  2 ++
 src/examples/test_ceres_2_lasers.cpp           |  4 ++++
 src/examples/test_eigen_quaternion.cpp         |  2 ++
 src/examples/test_image.cpp                    |  2 ++
 src/examples/test_local_param.cpp              |  1 +
 src/examples/test_motion.cpp                   |  2 ++
 src/examples/test_node_linked.cpp              |  4 ++++
 src/examples/test_state_quaternion.cpp         |  2 ++
 src/examples/test_virtual_hierarchy.cpp        | 10 ++++++++++
 src/examples/test_wolf_autodiffwrapper.cpp     |  2 ++
 src/examples/test_wolf_imported_graph.cpp      |  5 ++++-
 src/examples/test_wolf_prunning.cpp            |  6 +++++-
 src/examples/test_wolf_tree.cpp                |  5 ++---
 15 files changed, 50 insertions(+), 5 deletions(-)

diff --git a/src/examples/test_analytic_odom_constraint.cpp b/src/examples/test_analytic_odom_constraint.cpp
index 6453efe37..fcc7a71b4 100644
--- a/src/examples/test_analytic_odom_constraint.cpp
+++ b/src/examples/test_analytic_odom_constraint.cpp
@@ -18,6 +18,7 @@
 // EIGEN
 //#include <Eigen/CholmodSupport>
 
+namespace wolf {
 // inserts the sparse matrix 'ins' into the sparse matrix 'original' in the place given by 'row' and 'col' integers
 void insertSparseBlock(const Eigen::SparseMatrix<WolfScalar>& ins, Eigen::SparseMatrix<WolfScalar>& original, const unsigned int& row, const unsigned int& col)
 {
@@ -27,10 +28,13 @@ void insertSparseBlock(const Eigen::SparseMatrix<WolfScalar>& ins, Eigen::Sparse
 
   original.makeCompressed();
 }
+}
 
 
 int main(int argc, char** argv) 
 {
+    using namespace wolf;
+
     //Welcome message
     std::cout << std::endl << " ========= WOLF IMPORTED .graph TEST ===========" << std::endl << std::endl;
 
diff --git a/src/examples/test_autodiff.cpp b/src/examples/test_autodiff.cpp
index 0815cd7ed..aae3d005e 100644
--- a/src/examples/test_autodiff.cpp
+++ b/src/examples/test_autodiff.cpp
@@ -33,6 +33,7 @@
 #include "iri-algorithms/laser_scan_utils/corner_detector.h"
 #include "iri-algorithms/laser_scan_utils/entities.h"
 
+namespace wolf {
 //function travel around
 void motionCampus(unsigned int ii, Cpose3d & pose, double& displacement_, double& rotation_)
 {
@@ -49,9 +50,12 @@ void motionCampus(unsigned int ii, Cpose3d & pose, double& displacement_, double
     pose.moveForward(displacement_);
     pose.rt.setEuler(pose.rt.head() + rotation_, pose.rt.pitch(), pose.rt.roll());
 }
+}
 
 int main(int argc, char** argv)
 {
+    using namespace wolf;
+
     std::cout << "\n ========= 2D Robot with odometry and 2 LIDARs ===========\n";
 
     // USER INPUT ============================================================================================
diff --git a/src/examples/test_capture_laser_2D.cpp b/src/examples/test_capture_laser_2D.cpp
index ebf434d97..643186288 100644
--- a/src/examples/test_capture_laser_2D.cpp
+++ b/src/examples/test_capture_laser_2D.cpp
@@ -8,6 +8,8 @@
 //main
 int main(int argc, char *argv[])
 {
+    using namespace wolf;
+
     std::cout << std::endl << "CaptureLaser2D class test" << std::endl;
     std::cout << "========================================================" << std::endl;
     
diff --git a/src/examples/test_ceres_2_lasers.cpp b/src/examples/test_ceres_2_lasers.cpp
index 697f55df8..a1b5c86c8 100644
--- a/src/examples/test_ceres_2_lasers.cpp
+++ b/src/examples/test_ceres_2_lasers.cpp
@@ -32,6 +32,7 @@
 #include "iri-algorithms/laser_scan_utils/corner_detector.h"
 #include "iri-algorithms/laser_scan_utils/entities.h"
 
+namespace wolf {
 //function travel around
 void motionCampus(unsigned int ii, Cpose3d & pose, double& displacement_, double& rotation_)
 {
@@ -48,9 +49,12 @@ void motionCampus(unsigned int ii, Cpose3d & pose, double& displacement_, double
     pose.moveForward(displacement_);
     pose.rt.setEuler(pose.rt.head() + rotation_, pose.rt.pitch(), pose.rt.roll());
 }
+}
 
 int main(int argc, char** argv)
 {
+    using namespace wolf;
+
     std::cout << "\n ========= 2D Robot with odometry and 2 LIDARs ===========\n";
 
     // USER INPUT ============================================================================================
diff --git a/src/examples/test_eigen_quaternion.cpp b/src/examples/test_eigen_quaternion.cpp
index 0a696a82c..9eca8b910 100644
--- a/src/examples/test_eigen_quaternion.cpp
+++ b/src/examples/test_eigen_quaternion.cpp
@@ -10,6 +10,8 @@
 
 int main()
 {
+    using namespace wolf;
+
     std::cout << std::endl << "Eigen Quatenrnion test" << std::endl;
     
     WolfScalar q1[4]; 
diff --git a/src/examples/test_image.cpp b/src/examples/test_image.cpp
index 37eee84d2..a7765eab8 100644
--- a/src/examples/test_image.cpp
+++ b/src/examples/test_image.cpp
@@ -18,6 +18,8 @@
 
 int main(int argc, char** argv)
 {
+    using namespace wolf;
+
     /**
     if (argc != 2 || atoi(argv[1]) < 0 || atoi(argv[1]) > 1)
     {
diff --git a/src/examples/test_local_param.cpp b/src/examples/test_local_param.cpp
index 03eec4fd0..d355cb019 100644
--- a/src/examples/test_local_param.cpp
+++ b/src/examples/test_local_param.cpp
@@ -17,6 +17,7 @@ int main(){
 
     using namespace Eigen;
     using namespace std;
+    using namespace wolf;
 
     VectorXs x(22);
     MatrixXs M(1,12); // matrix dimensions do not matter, just storage size.
diff --git a/src/examples/test_motion.cpp b/src/examples/test_motion.cpp
index 45bc90ace..559697214 100644
--- a/src/examples/test_motion.cpp
+++ b/src/examples/test_motion.cpp
@@ -25,6 +25,8 @@
 
 int main()
 {
+    using namespace wolf;
+
     // time
     TimeStamp t0, t;
     t0.setToNow();
diff --git a/src/examples/test_node_linked.cpp b/src/examples/test_node_linked.cpp
index 9a67615b0..cd12c5bf9 100644
--- a/src/examples/test_node_linked.cpp
+++ b/src/examples/test_node_linked.cpp
@@ -4,6 +4,7 @@
 #include "wolf_problem.h"
 
 //namespaces
+namespace wolf {
 using namespace std;
 
 //id count init
@@ -92,9 +93,12 @@ class MeasurementN : public NodeLinked<FrameN,NodeTerminus>
         
 };
 
+} // namespace wolf
 
 int main()
 {
+    using namespace wolf;
+
     cout << endl << "Node class test" << endl;
     cout << "========================================================" << endl;
 
diff --git a/src/examples/test_state_quaternion.cpp b/src/examples/test_state_quaternion.cpp
index 3aba4fcbf..3ddef2d5d 100644
--- a/src/examples/test_state_quaternion.cpp
+++ b/src/examples/test_state_quaternion.cpp
@@ -14,6 +14,8 @@
 
 int main (void)
 {
+    using namespace wolf;
+
     // 3D
     StateBlock* pp = new StateBlock(3);
     StateQuaternion* op = new StateQuaternion;
diff --git a/src/examples/test_virtual_hierarchy.cpp b/src/examples/test_virtual_hierarchy.cpp
index 2d2e4848e..c6adba512 100644
--- a/src/examples/test_virtual_hierarchy.cpp
+++ b/src/examples/test_virtual_hierarchy.cpp
@@ -7,7 +7,9 @@
 
 #include <list>
 
+namespace wolf{
 
+}
 // BASE CLASSES
 
 /**
@@ -230,11 +232,15 @@ class SenNode : public Sen, public ChildOf<VehNode>, public Bot
         virtual ~SenNode() { }
 };
 
+} // namespace wolf
+
 /////////////////////
 // IMPLEMENTATIONS, here to avoid incomplete types and unwanted #includes
 /////////////////////
 
 #include <iostream>
+
+namespace wolf {
 using namespace std;
 
 template<class Child>
@@ -291,8 +297,12 @@ void VehNode::print()
 
 unsigned int N::id_count_ = 0;
 
+} // namespace wolf
+
 int main()
 {
+    using namespace wolf;
+
     // Create all nodes with up-pointers already set up
     VehNode V;
     SenNode S0(&V), S1(&V);
diff --git a/src/examples/test_wolf_autodiffwrapper.cpp b/src/examples/test_wolf_autodiffwrapper.cpp
index c351db56a..93fd4f8de 100644
--- a/src/examples/test_wolf_autodiffwrapper.cpp
+++ b/src/examples/test_wolf_autodiffwrapper.cpp
@@ -17,6 +17,8 @@
 
 int main(int argc, char** argv) 
 {
+    using namespace wolf;
+
     //Welcome message
     std::cout << std::endl << " ========= WOLF IMPORTED .graph TEST ===========" << std::endl << std::endl;
 
diff --git a/src/examples/test_wolf_imported_graph.cpp b/src/examples/test_wolf_imported_graph.cpp
index 1731d4385..b0bc70a6b 100644
--- a/src/examples/test_wolf_imported_graph.cpp
+++ b/src/examples/test_wolf_imported_graph.cpp
@@ -18,6 +18,7 @@
 // EIGEN
 //#include <Eigen/CholmodSupport>
 
+namespace wolf{
 // inserts the sparse matrix 'ins' into the sparse matrix 'original' in the place given by 'row' and 'col' integers
 void insertSparseBlock(const Eigen::SparseMatrix<WolfScalar>& ins, Eigen::SparseMatrix<WolfScalar>& original, const unsigned int& row, const unsigned int& col)
 {
@@ -27,10 +28,12 @@ void insertSparseBlock(const Eigen::SparseMatrix<WolfScalar>& ins, Eigen::Sparse
 
   original.makeCompressed();
 }
-
+}
 
 int main(int argc, char** argv) 
 {
+    using namespace wolf;
+
     //Welcome message
     std::cout << std::endl << " ========= WOLF IMPORTED .graph TEST ===========" << std::endl << std::endl;
 
diff --git a/src/examples/test_wolf_prunning.cpp b/src/examples/test_wolf_prunning.cpp
index f3329dcfd..065709f7c 100644
--- a/src/examples/test_wolf_prunning.cpp
+++ b/src/examples/test_wolf_prunning.cpp
@@ -18,7 +18,9 @@
 // EIGEN
 //#include <Eigen/CholmodSupport>
 
+namespace wolf{
 // inserts the sparse matrix 'ins' into the sparse matrix 'original' in the place given by 'row' and 'col' integers
+}
 void insertSparseBlock(const Eigen::SparseMatrix<WolfScalar>& ins, Eigen::SparseMatrix<WolfScalar>& original, const unsigned int& row, const unsigned int& col)
 {
   for (int k=0; k<ins.outerSize(); ++k)
@@ -27,10 +29,12 @@ void insertSparseBlock(const Eigen::SparseMatrix<WolfScalar>& ins, Eigen::Sparse
 
   original.makeCompressed();
 }
-
+}
 
 int main(int argc, char** argv) 
 {
+    using namespace wolf;
+
     //Welcome message
     std::cout << std::endl << " ========= WOLF IMPORTED .graph TEST ===========" << std::endl << std::endl;
 
diff --git a/src/examples/test_wolf_tree.cpp b/src/examples/test_wolf_tree.cpp
index 9e273a399..b215cd203 100644
--- a/src/examples/test_wolf_tree.cpp
+++ b/src/examples/test_wolf_tree.cpp
@@ -10,10 +10,10 @@
 //Wolf includes
 #include "wolf_manager.h"
 
-namespace wolf {
-
 int main(int argc, char** argv) 
 {
+    using namespace wolf;
+
     //Welcome message
     std::cout << std::endl << " ========= WOLF TREE test ===========" << std::endl << std::endl;
 
@@ -57,4 +57,3 @@ int main(int argc, char** argv)
     return 0;
 }
 
-} // namespace wolf
-- 
GitLab