hpp-template-corba  4.14.0
Template corba server
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 
18 namespace hpp {
19 namespace corba {
20 class ServerBase {
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);
43  bool initOmniINSPOA();
48  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 
79  int startCorbaServer();
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 
123 template <class T>
124 class 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);
157  ~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
PortableServer::POA_var main_poa()
Definition: server.hh:86
Definition: server.hh:18
int startCorbaServer()
Initialize CORBA server to process requests from clients.
bool initRootPOA(bool inMultiThread)
PortableServer::POA_var main_poa_
Definition: server.hh:95
PortableServer::POA_var ins_poa_
Definition: server.hh:95
Definition: server.hh:20
CORBA::ORB_var orb()
Definition: server.hh:91
Server(int argc, const char *argv[], const char *orb_identifier="", const char *options[][2]=0)
Constructor.
Definition: server.hxx:58
bool initORB(int argc, const char *argv[], const char *orb_identifier, const char *options[][2])
virtual ~ServerBase()
Shutdown CORBA server.
T & implementation()
Return a reference to the implementation.
Definition: server.hxx:69
~Server()
Shutdown CORBA server.
Definition: server.hxx:64
ServerBase(int argc, const char *argv[], const char *orb_identifier="", const char *options[][2]=0)
Constructor.
CosNaming::NamingContext_var hppContext_
Corba context.
Definition: server.hh:98
int processRequest(bool loop)
If ORB work is pending, process it.
void setServant(CORBA::Object_ptr obj)
Template CORBA server.
Definition: server.hh:124
bool initRootPOA(bool inMultiThread)
Definition: server.hxx:74
PortableServer::POA_var poa()
The Portable Object Adapter used to active the server.
Definition: server.hh:89
CORBA::ORB_var orb_
Definition: server.hh:94
PortableServer::POA_var poa_
Definition: server.hh:95