hpp-template-corba  4.9.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 <string>
15 # include <omniORB4/CORBA.h>
16 
17 namespace hpp
18 {
19  namespace corba
20  {
21  class ServerBase
22  {
23  public:
31  ServerBase (int argc, const char *argv[],
32  const char* orb_identifier="",
33  const char* options[][2]=0);
34 
43  bool initORB (int argc, const char *argv[],
44  const char* orb_identifier,
45  const char* options[][2]);
46  bool initRootPOA(bool inMultiThread);
47  bool initOmniINSPOA();
52  virtual ~ServerBase ();
54 
66  int startCorbaServer (const std::string& contextId,
67  const std::string& contextKind,
68  const std::string& objectId,
69  const std::string& objectKind);
70 
79  int startCorbaServer (const std::string& contextId,
80  const std::string& contextKind);
81 
83  int startCorbaServer ();
84 
87  int processRequest (bool loop);
88 
89  PortableServer::POA_var main_poa ()
90  {
91  return main_poa_;
92  }
93 
95  PortableServer::POA_var poa ()
96  {
97  return poa_;
98  }
99 
100  CORBA::ORB_var orb()
101  {
102  return orb_;
103  }
104 
105  protected:
106  CORBA::ORB_var orb_;
107  PortableServer::POA_var poa_, main_poa_, ins_poa_;
108 
110  CosNaming::NamingContext_var hppContext_;
111 
112  void setServant(CORBA::Object_ptr obj);
113 
114  private:
116  CORBA::Object_var servant_;
117 
119  bool createHppContext (const std::string& id, const std::string kind);
120 
122  bool bindObjectToName (CORBA::Object_ptr objref,
123  CosNaming::Name objectName);
124 
126  bool bindObjectToName (CosNaming::NamingContext_ptr context,
127  CORBA::Object_ptr objref,
128  CosNaming::Name objectName);
129  };
130 
137  template <class T> class Server : public ServerBase
138  {
139  public:
147  Server (int argc, const char *argv[],
148  const char* orb_identifier="",
149  const char* options[][2]=0);
150 
160  bool initRootPOA(bool inMultiThread);
166  bool initOmniINSPOA(const char* object_id);
171  ~Server ();
173 
175  T& implementation();
176 
177  private:
178  T* impl_;
179 
182  PortableServer::ObjectId_var servantId_;
183 
185  CosNaming::NamingContext_var hppContext_;
186 
188  bool createHppContext (const std::string& id, const std::string kind);
189 
191  bool bindObjectToName (CORBA::Object_ptr objref,
192  CosNaming::Name objectName);
193 
195  bool bindObjectToName (CosNaming::NamingContext_ptr context,
196  CORBA::Object_ptr objref,
197  CosNaming::Name objectName);
198 
199 
203  void deactivateAndDestroyServers ();
204  };
205 
206  } // end of namespace corba.
207 } // end of namespace hpp.
208 
210 #endif
PortableServer::POA_var main_poa()
Definition: server.hh:89
Definition: server.hh:17
int startCorbaServer()
Initialize CORBA server to process requests from clients.
bool initRootPOA(bool inMultiThread)
PortableServer::POA_var main_poa_
Definition: server.hh:107
PortableServer::POA_var ins_poa_
Definition: server.hh:107
Definition: server.hh:21
CORBA::ORB_var orb()
Definition: server.hh:100
bool initORB(int argc, const char *argv[], const char *orb_identifier, const char *options[][2])
virtual ~ServerBase()
Shutdown CORBA server.
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:110
int processRequest(bool loop)
If ORB work is pending, process it.
void setServant(CORBA::Object_ptr obj)
Template CORBA server.
Definition: server.hh:137
PortableServer::POA_var poa()
The Portable Object Adapter used to active the server.
Definition: server.hh:95
CORBA::ORB_var orb_
Definition: server.hh:106
PortableServer::POA_var poa_
Definition: server.hh:107