hpp-corbaserver: include/hpp/corbaserver/problem-solver-map.hh Source File

hpp-corbaserver 9.0.2 Corba server for Humanoid Path Planner applications

Loading...
Searching...
No Matches
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
34#include "hpp/corbaserver/config.hh"
35#include "hpp/corbaserver/fwd.hh"
36#include "hpp/core/fwd.hh"
37
38 namespace hpp {
39 namespace corbaServer {
40 class HPP_CORBASERVER_DLLAPI ProblemSolverMap {
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
50 ProblemSolverMap(const ProblemSolverMap& map);
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
hpp::corbaServer::ProblemSolverMap
Definition problem-solver-map.hh:40
hpp::corbaServer::ProblemSolverMap::selected
void selected(const std::string &name)
hpp::corbaServer::ProblemSolverMap::replaceSelected
void replaceSelected(core::ProblemSolverPtr_t ps)
hpp::corbaServer::ProblemSolverMap::operator->
core::ProblemSolverPtr_t operator->()
hpp::corbaServer::ProblemSolverMap::ProblemSolverMap
ProblemSolverMap(core::ProblemSolverPtr_t init, const std::string &name="default")
hpp::corbaServer::ProblemSolverMap::selectedName
const std::string & selectedName() const
Definition problem-solver-map.hh:74
hpp::corbaServer::ProblemSolverMap::has
bool has(const std::string &name) const
hpp::corbaServer::ProblemSolverMap::remove
void remove(const std::string &name)
hpp::corbaServer::ProblemSolverMap::selected
core::ProblemSolverPtr_t selected() const
hpp::corbaServer::ProblemSolverMap::ProblemMapPtr_t
shared_ptr< ProblemMap_t > ProblemMapPtr_t
Definition problem-solver-map.hh:43
hpp::corbaServer::ProblemSolverMap::add
void add(const std::string &name, core::ProblemSolverPtr_t ps)
hpp::corbaServer::ProblemSolverMap::mutex_t
boost::mutex mutex_t
Definition problem-solver-map.hh:44
hpp::corbaServer::ProblemSolverMap::keys
ReturnType keys() const
Definition problem-solver-map.hh:65
hpp::corbaServer::ProblemSolverMap::get
core::ProblemSolverPtr_t get(const std::string &name) const
hpp::corbaServer::ProblemSolverMap::ProblemMap_t
std::map< std::string, core::ProblemSolverPtr_t > ProblemMap_t
Definition problem-solver-map.hh:42
hpp::corbaServer::ProblemSolverMap::ProblemSolverMap
ProblemSolverMap(const ProblemSolverMap &map)
hpp::corbaServer::ProblemSolverMap::mutexPtr_t
shared_ptr< mutex_t > mutexPtr_t
Definition problem-solver-map.hh:45
hpp::core::ProblemSolver
config.hh
HPP_CORBASERVER_DLLAPI
#define HPP_CORBASERVER_DLLAPI
Definition config.hh:88
fwd.hh
init
void init(const ConfigurationShooterWkPtr_t &weak)
hpp
Implement CORBA interface `‘Obstacle’'.