hpp-corbaserver 6.0.0
Corba server for Humanoid Path Planner applications
Loading...
Searching...
No Matches
basic-server.hh
Go to the documentation of this file.
1// Copyright (C) 2019 CNRS-LAAS
2// Author: Joseph Mirabel
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_BASIC_SERVER_HH
30#define HPP_CORBASERVER_BASIC_SERVER_HH
31
32#include <hpp/corba/template/server.hh>
34#include <hpp/util/exception.hh>
35#include <stdexcept>
36
37#include "obstacle.impl.hh"
38#include "problem.impl.hh"
39#include "robot.impl.hh"
40
41namespace hpp {
42namespace corbaServer {
43namespace impl {
44class Obstacle;
45class Problem;
46class Robot;
47} // namespace impl
48
50 public:
51 BasicServer(Server* parent);
52
54
56 void startCorbaServer(const std::string& contextId,
57 const std::string& contextKind);
58
59 ::CORBA::Object_ptr servant(const std::string& name) const;
60
61 std::string name() const;
62
63 private:
64 corba::Server<impl::Obstacle>* obstacleImpl_;
65 corba::Server<impl::Problem>* problemImpl_;
66 corba::Server<impl::Robot>* robotImpl_;
67}; // class ServerPlugin
68
70 : ServerPlugin(parent),
71 obstacleImpl_(NULL),
72 problemImpl_(NULL),
73 robotImpl_(NULL) {}
74
76 if (obstacleImpl_) delete obstacleImpl_;
77 if (problemImpl_) delete problemImpl_;
78 if (robotImpl_) delete robotImpl_;
79}
80
81std::string BasicServer::name() const { return "basic"; }
82
85 const std::string& contextKind) {
87 "obstacle");
88 initializeTplServer(problemImpl_, contextId, contextKind, name(), "problem");
89 initializeTplServer(robotImpl_, contextId, contextKind, name(), "robot");
90
91 obstacleImpl_->implementation().setServer(this);
92 problemImpl_->implementation().setServer(this);
93 robotImpl_->implementation().setServer(this);
94}
95
96::CORBA::Object_ptr BasicServer::servant(const std::string& name) const {
97 if (name == "obstacle") return obstacleImpl_->implementation()._this();
98 if (name == "problem") return problemImpl_->implementation()._this();
99 if (name == "robot") return robotImpl_->implementation()._this();
100 throw std::invalid_argument("No servant " + name);
101}
102} // namespace corbaServer
103} // namespace hpp
104
105#endif // HPP_CORBASERVER_SERVER_PLUGIN_HH
Definition obstacle-idl.hh:94
Definition problem-idl.hh:138
Definition robot-idl.hh:98
Definition basic-server.hh:49
void startCorbaServer(const std::string &contextId, const std::string &contextKind)
Start corba server.
Definition basic-server.hh:84
std::string name() const
Definition basic-server.hh:81
~BasicServer()
Definition basic-server.hh:75
::CORBA::Object_ptr servant(const std::string &name) const
Definition basic-server.hh:96
BasicServer(Server *parent)
Definition basic-server.hh:69
Definition server-plugin.hh:50
void initializeTplServer(corba::Server< T > *&server, const std::string &contextId, const std::string &contextKind, const std::string &objectId, const std::string &objectKind)
Definition server-plugin.hh:82
Implementation of Hpp module Corba server.
Definition server.hh:78
#define HPP_CORBASERVER_LOCAL
Definition config.hh:92
ReturnType::Object_var makeServantDownCast(Server *server, const typename ServantBaseType::Storage &t)
Definition servant-base.hh:407
Implement CORBA interface `‘Obstacle’'.
Definition client.hh:46