hpp-corbaserver  4.9.0
Corba server for Humanoid Path Planner applications
problem-solver-map.hh
Go to the documentation of this file.
1 // Copyright (c) 2016, Joseph Mirabel
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 // This file is part of hpp-corbaserver.
5 // hpp-corbaserver is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // hpp-corbaserver is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // hpp-corbaserver. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HPP_CORBASERVER_PROBLEM_SOLVER_MAP_HH
18 # define HPP_CORBASERVER_PROBLEM_SOLVER_MAP_HH
19 # include <map>
20 # include <boost/thread/mutex.hpp>
21 
22 # include "hpp/corbaserver/fwd.hh"
23 # include "hpp/corbaserver/config.hh"
24 
25 # include "hpp/core/fwd.hh"
26 
27 namespace hpp
28 {
29  namespace corbaServer
30  {
31  class HPP_CORBASERVER_DLLAPI ProblemSolverMap {
32  public:
33  typedef std::map<std::string, core::ProblemSolverPtr_t> ProblemMap_t;
34  typedef boost::shared_ptr<ProblemMap_t> ProblemMapPtr_t;
35  typedef boost::mutex mutex_t;
36  typedef boost::shared_ptr<mutex_t> mutexPtr_t;
37 
39  const std::string& name = "default");
40 
42 
43  core::ProblemSolverPtr_t operator-> ();
44  operator core::ProblemSolverPtr_t ();
45 
46  core::ProblemSolverPtr_t selected () const;
47  core::ProblemSolverPtr_t get (const std::string& name) const;
48  void selected (const std::string& name);
49 
50  bool has (const std::string& name) const;
51  void add (const std::string& name, core::ProblemSolverPtr_t ps);
52  void remove (const std::string& name);
53  void replaceSelected (core::ProblemSolverPtr_t ps);
54 
55  template <typename ReturnType> ReturnType keys () const
56  {
57  mutex_t::scoped_lock lock (*mutex_);
58  ReturnType l;
59  for (ProblemMap_t::const_iterator it = map_->begin ();
60  it != map_->end (); ++it)
61  l.push_back (it->first);
62  return l;
63  }
64 
65  const std::string& selectedName () const
66  {
67  return selected_;
68  }
69 
70  private:
71  std::string selected_;
72  ProblemMapPtr_t map_;
73  mutexPtr_t mutex_;
74  };
75  } // end of namespace corbaServer.
76 } // end of namespace hpp.
77 
78 #endif
Implement CORBA interface ``Obstacle&#39;&#39;.
boost::shared_ptr< ProblemMap_t > ProblemMapPtr_t
Definition: problem-solver-map.hh:34
boost::shared_ptr< mutex_t > mutexPtr_t
Definition: problem-solver-map.hh:36
const std::string & selectedName() const
Definition: problem-solver-map.hh:65
ProblemSolver * ProblemSolverPtr_t
void init(const ConfigurationShooterWkPtr_t &weak)
std::map< std::string, core::ProblemSolverPtr_t > ProblemMap_t
Definition: problem-solver-map.hh:33
Definition: problem-solver-map.hh:31
boost::mutex mutex_t
Definition: problem-solver-map.hh:35
ReturnType keys() const
Definition: problem-solver-map.hh:55