CARMA C++
Server.h
1 #ifndef CARMA_CORBA_SERVER_H
2 #define CARMA_CORBA_SERVER_H
3 
4 #include "carma/util/Program.h"
5 
6 #include <memory>
7 #include <string>
8 
9 namespace carma {
10 namespace corba {
11 
12  class Client;
13 
22  class Server {
23  public:
24 
32  explicit Server( int argc, char * argv[], int rrtt = 60 );
33 
37  virtual ~Server( );
38 
44  template< template< typename > class T, typename S >
45  void addServant( S & servant,
46  const ::std::string & nameserverName );
47 
53  template< template< typename > class T , typename S >
54  void addServant( S & servant,
55  typename T< S >::_stub_ptr_type & corbaClientPtr );
56 
66  template< typename S, typename N >
67  void addNotificationServantFunctor( S & servant,
68  const ::std::string & channelName,
69  const ::std::string & proxyName );
70 
74  void work( );
75 
80  void run( bool inSeparateThread = false );
81 
85  void stop( );
86 
91  bool terminated( ) const;
92 
93  private:
94 
95  friend Client & carma::util::ProgramBase::getCorbaClient();
96  Client & client();
97 
98  // No copy
99  Server( const Server & );
100  Server & operator=( const Server & );
101 
102  // Aggressively hide everything
103  struct PrivateImplementation; // Visible to .cc implementation only.
104  std::auto_ptr< PrivateImplementation > privateImpl_;
105 
106  struct PrivateInline; // Visible to .inl templatized implementation
107  std::auto_ptr< PrivateInline > privateInl_;
108  };
109 
110 }} // namespace carma::corba
111 
112 // Include the implementation in a separate file to avoid clutter.
113 #include "carma/corba/Server.inl"
114 
115 #endif
virtual ~Server()
Destructor.
void work()
Service remote requests if pending (non blocking).
bool terminated() const
Check if server has terminated, including via the IMR.
void run(bool inSeparateThread=false)
Service remote requests continuously (blocks).
Server(int argc, char *argv[], int rrtt=60)
Initialize CORBA server runtime.
Class to encapsulate CORBA client functionality in CARMA.
Definition: Client.h:26
void addServant(S &servant, const ::std::string &nameserverName)
Add servant S, incarnate with IDL generated tie T and publish.
void stop()
Stop serving remote requests permanently.
Class for creating, managing and serving requests to CORBA servants.
Definition: Server.h:22
void addNotificationServantFunctor(S &servant, const ::std::string &channelName, const ::std::string &proxyName)
Add servant to process IDL defined notifications on given channel.