hpp-corbaserver  6.0.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 
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // 1. Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27 // DAMAGE.
28 
29 #ifndef HPP_CORBASERVER_PROBLEM_SOLVER_MAP_HH
30 #define HPP_CORBASERVER_PROBLEM_SOLVER_MAP_HH
31 #include <boost/thread/mutex.hpp>
32 #include <map>
33 
35 #include "hpp/corbaserver/fwd.hh"
36 #include "hpp/core/fwd.hh"
37 
38 namespace hpp {
39 namespace corbaServer {
41  public:
42  typedef std::map<std::string, core::ProblemSolverPtr_t> ProblemMap_t;
43  typedef shared_ptr<ProblemMap_t> ProblemMapPtr_t;
44  typedef boost::mutex mutex_t;
45  typedef shared_ptr<mutex_t> mutexPtr_t;
46 
47  ProblemSolverMap(core::ProblemSolverPtr_t init,
48  const std::string& name = "default");
49 
51 
52  core::ProblemSolverPtr_t operator->();
53  operator core::ProblemSolverPtr_t();
54 
55  core::ProblemSolverPtr_t selected() const;
56  core::ProblemSolverPtr_t get(const std::string& name) const;
57  void selected(const std::string& name);
58 
59  bool has(const std::string& name) const;
60  void add(const std::string& name, core::ProblemSolverPtr_t ps);
61  void remove(const std::string& name);
62  void replaceSelected(core::ProblemSolverPtr_t ps);
63 
64  template <typename ReturnType>
65  ReturnType keys() const {
66  mutex_t::scoped_lock lock(*mutex_);
67  ReturnType l;
68  for (ProblemMap_t::const_iterator it = map_->begin(); it != map_->end();
69  ++it)
70  l.push_back(it->first);
71  return l;
72  }
73 
74  const std::string& selectedName() const { return selected_; }
75 
76  private:
77  std::string selected_;
78  ProblemMapPtr_t map_;
79  mutexPtr_t mutex_;
80 };
81 } // end of namespace corbaServer.
82 } // end of namespace hpp.
83 
84 #endif
Definition: problem-solver-map.hh:40
void selected(const std::string &name)
const std::string & selectedName() const
Definition: problem-solver-map.hh:74
void replaceSelected(core::ProblemSolverPtr_t ps)
core::ProblemSolverPtr_t operator->()
ProblemSolverMap(core::ProblemSolverPtr_t init, const std::string &name="default")
bool has(const std::string &name) const
void remove(const std::string &name)
core::ProblemSolverPtr_t selected() const
shared_ptr< ProblemMap_t > ProblemMapPtr_t
Definition: problem-solver-map.hh:43
void add(const std::string &name, core::ProblemSolverPtr_t ps)
boost::mutex mutex_t
Definition: problem-solver-map.hh:44
ReturnType keys() const
Definition: problem-solver-map.hh:65
core::ProblemSolverPtr_t get(const std::string &name) const
std::map< std::string, core::ProblemSolverPtr_t > ProblemMap_t
Definition: problem-solver-map.hh:42
ProblemSolverMap(const ProblemSolverMap &map)
shared_ptr< mutex_t > mutexPtr_t
Definition: problem-solver-map.hh:45
#define HPP_CORBASERVER_DLLAPI
Definition: config.hh:88
Implement CORBA interface `‘Obstacle’'.
Definition: client.hh:46