hpp-template-corba 4.14.0
Template corba server
Loading...
Searching...
No Matches
server.hh
Go to the documentation of this file.
1// Copyright (C) 2009, 2010 by Florent Lamiraux, Thomas Moulard, JRL.
2//
3// This file is part of hpp-template-corba
4//
5// This software is provided "as is" without warranty of any kind,
6// either expressed or implied, including but not limited to the
7// implied warranties of fitness for a particular purpose.
8//
9// See the COPYING file for more information.
10
11#ifndef HPP_CORBA_SERVER_HH
12#define HPP_CORBA_SERVER_HH
13
14#include <omniORB4/CORBA.h>
15
16#include <string>
17
18namespace hpp {
19namespace corba {
21 public:
29 ServerBase(int argc, const char* argv[], const char* orb_identifier = "",
30 const char* options[][2] = 0);
31
40 bool initORB(int argc, const char* argv[], const char* orb_identifier,
41 const char* options[][2]);
42 bool initRootPOA(bool inMultiThread);
49 virtual ~ServerBase();
50
62 int startCorbaServer(const std::string& contextId,
63 const std::string& contextKind,
64 const std::string& objectId,
65 const std::string& objectKind);
66
75 int startCorbaServer(const std::string& contextId,
76 const std::string& contextKind);
77
80
84 int processRequest(bool loop);
85
86 PortableServer::POA_var main_poa() { return main_poa_; }
87
89 PortableServer::POA_var poa() { return poa_; }
90
91 CORBA::ORB_var orb() { return orb_; }
92
93 protected:
94 CORBA::ORB_var orb_;
95 PortableServer::POA_var poa_, main_poa_, ins_poa_;
96
98 CosNaming::NamingContext_var hppContext_;
99
100 void setServant(CORBA::Object_ptr obj);
101
102 private:
104 CORBA::Object_var servant_;
105
107 bool createHppContext(const std::string& id, const std::string kind);
108
110 bool bindObjectToName(CORBA::Object_ptr objref, CosNaming::Name objectName);
111
113 bool bindObjectToName(CosNaming::NamingContext_ptr context,
114 CORBA::Object_ptr objref, CosNaming::Name objectName);
115};
116
123template <class T>
124class Server : public ServerBase {
125 public:
133 Server(int argc, const char* argv[], const char* orb_identifier = "",
134 const char* options[][2] = 0);
135
145 bool initRootPOA(bool inMultiThread);
152 bool initOmniINSPOA(const char* object_id);
158 ~Server();
159
161 T& implementation();
162
163 private:
164 T* impl_;
165
168 PortableServer::ObjectId_var servantId_;
169
171 CosNaming::NamingContext_var hppContext_;
172
174 bool createHppContext(const std::string& id, const std::string kind);
175
177 bool bindObjectToName(CORBA::Object_ptr objref, CosNaming::Name objectName);
178
180 bool bindObjectToName(CosNaming::NamingContext_ptr context,
181 CORBA::Object_ptr objref, CosNaming::Name objectName);
182
186 void deactivateAndDestroyServers();
187};
188
189} // end of namespace corba.
190} // end of namespace hpp.
191
193#endif
Definition: server.hh:20
PortableServer::POA_var poa_
Definition: server.hh:95
virtual ~ServerBase()
Shutdown CORBA server.
PortableServer::POA_var main_poa()
Definition: server.hh:86
CosNaming::NamingContext_var hppContext_
Corba context.
Definition: server.hh:98
PortableServer::POA_var main_poa_
Definition: server.hh:95
bool initORB(int argc, const char *argv[], const char *orb_identifier, const char *options[][2])
PortableServer::POA_var ins_poa_
Definition: server.hh:95
void setServant(CORBA::Object_ptr obj)
int startCorbaServer(const std::string &contextId, const std::string &contextKind, const std::string &objectId, const std::string &objectKind)
Initialize CORBA server to process requests from clients and declare it to the NameService (DNS for C...
CORBA::ORB_var orb()
Definition: server.hh:91
int startCorbaServer(const std::string &contextId, const std::string &contextKind)
Initialize CORBA server to process requests from clients and declare it to the NameService (DNS for C...
CORBA::ORB_var orb_
Definition: server.hh:94
bool initRootPOA(bool inMultiThread)
ServerBase(int argc, const char *argv[], const char *orb_identifier="", const char *options[][2]=0)
Constructor.
int processRequest(bool loop)
If ORB work is pending, process it.
PortableServer::POA_var poa()
The Portable Object Adapter used to active the server.
Definition: server.hh:89
int startCorbaServer()
Initialize CORBA server to process requests from clients.
Template CORBA server.
Definition: server.hh:124
bool initRootPOA(bool inMultiThread)
Definition: server.hxx:74
T & implementation()
Return a reference to the implementation.
Definition: server.hxx:69
~Server()
Shutdown CORBA server.
Definition: server.hxx:64
Definition: server.hh:18