From fba9c2a771713876a7959e68172e64c4bd912299 Mon Sep 17 00:00:00 2001 From: Joseph Mirabel <jmirabel@laas.fr> Date: Fri, 4 Dec 2015 17:04:44 +0100 Subject: [PATCH] Update to changes in hpp-core regarding Container --- CMakeLists.txt | 1 - include/hpp/manipulation/container.hh | 108 -------------------- include/hpp/manipulation/device.hh | 15 +-- include/hpp/manipulation/graph-optimizer.hh | 2 +- include/hpp/manipulation/problem-solver.hh | 10 +- src/problem-solver.cc | 19 ++-- 6 files changed, 26 insertions(+), 129 deletions(-) delete mode 100644 include/hpp/manipulation/container.hh diff --git a/CMakeLists.txt b/CMakeLists.txt index 16e200e..31ad631 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,6 @@ CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/doc/main.hh.in SET (${PROJECT_NAME}_HEADERS include/hpp/manipulation/fwd.hh - include/hpp/manipulation/container.hh include/hpp/manipulation/axial-handle.hh include/hpp/manipulation/handle.hh include/hpp/manipulation/problem.hh diff --git a/include/hpp/manipulation/container.hh b/include/hpp/manipulation/container.hh deleted file mode 100644 index 97c8344..0000000 --- a/include/hpp/manipulation/container.hh +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) 2015, LAAS-CNRS -// Authors: Joseph Mirabel (joseph.mirabel@laas.fr) -// -// This file is part of hpp-manipulation. -// hpp-manipulation is free software: you can redistribute it -// and/or modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation, either version -// 3 of the License, or (at your option) any later version. -// -// hpp-manipulation is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Lesser Public License for more details. You should have -// received a copy of the GNU Lesser General Public License along with -// hpp-manipulation. If not, see <http://www.gnu.org/licenses/>. - -#ifndef HPP_MANIPULATION_CONTAINER_HH -# define HPP_MANIPULATION_CONTAINER_HH - -# include <map> -# include <list> -# include <boost/smart_ptr/shared_ptr.hpp> - -namespace hpp { - namespace manipulation { - template < typename Element, typename Key = std::string> - class HPP_MANIPULATION_DLLAPI Container - { - public: - typedef std::map <Key, Element> ElementMap_t; - typedef Key Key_t; - typedef Element Element_t; - - /// Add an element - void add (const Key& name, const Element& element) - { - map_[name] = element; - } - - /// Return the element named name - const Element& get (const Key& name) const - { - typename ElementMap_t::const_iterator it = map_.find (name); - if (it == map_.end ()) return default_; - return it->second; - } - - /// Return a list of all elements - /// \tparam ReturnType must have a push_back method. - template <typename ReturnType> - ReturnType getAllAs () const - { - ReturnType l; - for (typename ElementMap_t::const_iterator it = map_.begin (); - it != map_.end (); ++it) - l.push_back (it->second); - return l; - } - - template <typename ReturnType> - ReturnType getKeys () const - { - ReturnType l; - for (typename ElementMap_t::const_iterator it = map_.cbegin (); - it != map_.cend (); ++it) - l.push_back (it->first); - return l; - } - - /// Return the underlying map. - const ElementMap_t& getAll () const - { - return map_; - } - - /// Print object in a stream - std::ostream& print (std::ostream& os) const - { - for (typename ElementMap_t::const_iterator it = map_.begin (); - it != map_.end (); ++it) { - os << it->first << " : " << it->second << std::endl; - } - return os; - } - - /// Print object in a stream - std::ostream& printPointer (std::ostream& os) const - { - for (typename ElementMap_t::const_iterator it = map_.begin (); - it != map_.end (); ++it) { - os << it->first << " : " << *(it->second) << std::endl; - } - return os; - } - - protected: - /// Constructor - Container () : map_ () - {} - - private: - ElementMap_t map_; - /// Element returned by method get when key does not belong to map. - Element default_; - }; // class Container - } // namespace manipulation -} // namespace hpp -#endif // HPP_MANIPULATION_CONTAINER_HH diff --git a/include/hpp/manipulation/device.hh b/include/hpp/manipulation/device.hh index ddde20a..6a7a7c0 100644 --- a/include/hpp/manipulation/device.hh +++ b/include/hpp/manipulation/device.hh @@ -21,10 +21,10 @@ # define HPP_MANIPULATION_DEVICE_HH # include <hpp/model/humanoid-robot.hh> +# include <hpp/core/container.hh> # include "hpp/manipulation/fwd.hh" # include "hpp/manipulation/config.hh" -# include "hpp/manipulation/container.hh" namespace hpp { namespace manipulation { @@ -35,8 +35,9 @@ namespace hpp { /// /// This class also contains model::Gripper, Handle and \ref JointAndTriangles_t class HPP_MANIPULATION_DLLAPI Device : public model::HumanoidRobot, - public Container <HandlePtr_t>, public Container <model::GripperPtr_t>, - public Container <JointAndShapes_t> + public core::Container <HandlePtr_t>, + public core::Container <model::GripperPtr_t>, + public core::Container <JointAndShapes_t> { public: typedef model::HumanoidRobot Parent_t; @@ -63,21 +64,21 @@ namespace hpp { template <typename Element> const Element& get (const std::string& name) const { - return Container <Element>::get (name); + return core::Container <Element>::get (name); } /// Get the underlying map of a container template <typename Element> - const typename Container<Element>::ElementMap_t& getAll () const + const typename core::Container<Element>::ElementMap_t& getAll () const { - return Container <Element>::getAll (); + return core::Container <Element>::getAll (); } /// Add an element to a container template <typename Element> void add (const std::string& name, const Element& element) { - Container <Element>::add (name, element); + core::Container <Element>::add (name, element); } /// \} diff --git a/include/hpp/manipulation/graph-optimizer.hh b/include/hpp/manipulation/graph-optimizer.hh index bd2456d..1351464 100644 --- a/include/hpp/manipulation/graph-optimizer.hh +++ b/include/hpp/manipulation/graph-optimizer.hh @@ -47,7 +47,7 @@ namespace hpp { class HPP_MANIPULATION_DLLAPI GraphOptimizer : public PathOptimizer { public: - typedef core::ProblemSolver::PathOptimizerBuilder_t PathOptimizerBuilder_t; + typedef core::PathOptimizerBuilder_t PathOptimizerBuilder_t; template <typename TraitsOrInnerType> static GraphOptimizerPtr_t create (const core::Problem& problem); diff --git a/include/hpp/manipulation/problem-solver.hh b/include/hpp/manipulation/problem-solver.hh index db2e558..fe97d85 100644 --- a/include/hpp/manipulation/problem-solver.hh +++ b/include/hpp/manipulation/problem-solver.hh @@ -21,16 +21,18 @@ # include <map> # include <hpp/model/device.hh> # include <hpp/core/problem-solver.hh> +# include <hpp/core/container.hh> # include "hpp/manipulation/fwd.hh" # include "hpp/manipulation/deprecated.hh" # include "hpp/manipulation/device.hh" -# include "hpp/manipulation/container.hh" # include "hpp/manipulation/graph/fwd.hh" namespace hpp { namespace manipulation { - class HPP_MANIPULATION_DLLAPI ProblemSolver : public core::ProblemSolver, - public Container <LockedJointPtr_t>, public Container <JointAndShapes_t> + class HPP_MANIPULATION_DLLAPI ProblemSolver : + public core::ProblemSolver, + public core::Container <LockedJointPtr_t>, + public core::Container <JointAndShapes_t> { public: typedef core::ProblemSolver parent_t; @@ -143,7 +145,7 @@ namespace hpp { /// Get the underlying map of a container template <typename Element> - const typename Container<Element>::ElementMap_t& getAll () const + const typename core::Container<Element>::ElementMap_t& getAll () const { return Container <Element>::getAll (); } diff --git a/src/problem-solver.cc b/src/problem-solver.cc index 359e0a0..9a9ed0d 100644 --- a/src/problem-solver.cc +++ b/src/problem-solver.cc @@ -68,21 +68,24 @@ namespace hpp { ProblemSolver::ProblemSolver () : core::ProblemSolver (), robot_ (), problem_ (0x0), graspsMap_() { - addPathPlannerType ("M-RRT", ManipulationPlanner::create); - addPathValidationType ("Graph-Discretized", + add <core::PathPlannerBuilder_t> ("M-RRT", ManipulationPlanner::create); + using core::PathValidationBuilder_t; + add <PathValidationBuilder_t> ("Graph-Discretized", GraphPathValidation::create <core::DiscretizedCollisionChecking>); - addPathValidationType ("Graph-Progressive", GraphPathValidation::create < + add <PathValidationBuilder_t> ("Graph-Progressive", + GraphPathValidation::create < core::continuousCollisionChecking::Progressive >); - addPathOptimizerType ("Graph-RandomShortcut", + using core::PathOptimizerBuilder_t; + add <PathOptimizerBuilder_t> ("Graph-RandomShortcut", GraphOptimizer::create <core::RandomShortcut>); - addPathOptimizerType ("PartialShortcut", core::pathOptimization:: + add <PathOptimizerBuilder_t> ("PartialShortcut", core::pathOptimization:: PartialShortcut::createWithTraits <PartialShortcutTraits>); - addPathOptimizerType ("Graph-PartialShortcut", + add <PathOptimizerBuilder_t> ("Graph-PartialShortcut", GraphOptimizer::create <core::pathOptimization::PartialShortcut>); - addPathOptimizerType ("ConfigOptimization", + add <PathOptimizerBuilder_t> ("ConfigOptimization", core::pathOptimization::ConfigOptimization::createWithTraits <pathOptimization::ConfigOptimizationTraits>); - addPathOptimizerType ("Graph-ConfigOptimization", + add <PathOptimizerBuilder_t> ("Graph-ConfigOptimization", GraphOptimizer::create < GraphConfigOptimizationTraits <pathOptimization::ConfigOptimizationTraits> -- GitLab