provide access to client_connection singletons and call-handling function More...
#include <client_wrapper.hxx>
Public Member Functions | |
ConnectionWrapper () | |
virtual | ~ConnectionWrapper () |
virtual client_connection * | get_connection ()=0 |
return active connection, create new one if not existing | |
virtual bool | handle (command_client *stubBase, boost::function< void() > f) |
this function is called on every execution of a method on a server | |
long long | get_command_timeout_usec (void) |
void | set_command_timeout_usec (long long _command_timeout_usec) |
long long | get_hello_timeout_usec (void) |
void | set_hello_timeout_usec (long long _hello_timeout_usec) |
virtual void | set_logging (std::ostream *_logstream, log_level_values _log_level) |
activate logging to the given stream. everything above the given level is logged. | |
std::ostream * | get_logstream (log_level_values level) |
get pointer to logging stream, returns NULL if no logging needed | |
Protected Member Functions | |
void | set_logging_on_connection (client_connection &c) |
always call this when you got a new connection to transfer logging settings | |
Protected Attributes | |
log_level_values | log_level |
std::ostream * | logstream |
Private Attributes | |
long long | command_timeout_usec |
long long | hello_timeout_usec |
provide access to client_connection singletons and call-handling function
This is an abstact base class for use with T2nSingletonWrapper. It provides access to the singleton-client_connection and offers a handle-method which is used for every call to a method on a t2n-server.
libt2n::ConnectionWrapper::ConnectionWrapper | ( | ) | [inline] |
virtual libt2n::ConnectionWrapper::~ConnectionWrapper | ( | ) | [inline, virtual] |
long long libt2n::ConnectionWrapper::get_command_timeout_usec | ( | void | ) | [inline] |
References command_timeout_usec.
virtual client_connection* libt2n::ConnectionWrapper::get_connection | ( | ) | [pure virtual] |
return active connection, create new one if not existing
Return a pointer to an active client_connection. Use detail-data stored within the derived class to create a new connection if needed, otherwise return an alredy active connection. The derived class has to take care of destroying the connection when not needed anymore.
Implemented in libt2n::BasicSocketWrapper, and libt2n::ReconnectIgnoreFailureSocketWrapper.
long long libt2n::ConnectionWrapper::get_hello_timeout_usec | ( | void | ) | [inline] |
References hello_timeout_usec.
std::ostream * libt2n::ConnectionWrapper::get_logstream | ( | log_level_values | level | ) |
virtual bool libt2n::ConnectionWrapper::handle | ( | command_client * | stubBase, | |
boost::function< void() > | f | |||
) | [inline, virtual] |
this function is called on every execution of a method on a server
stubBase | pointer to the command_client executing the call | |
f | boost::function object containing the method to call and all parameters |
true | if the call was successful and the original return-value of the called function can be used false if T2nSingletonWrapper has to create a return-value with the default-constructor |
T2nSingletonWrapper will call this function on every execution of a server-side method. This version will just call the function without any special treatment. You can overload this function to implement different error handling strategies.
Reimplemented in libt2n::ReconnectSocketWrapper, and libt2n::ReconnectIgnoreFailureSocketWrapper.
void libt2n::ConnectionWrapper::set_command_timeout_usec | ( | long long | _command_timeout_usec | ) | [inline] |
References command_timeout_usec.
void libt2n::ConnectionWrapper::set_hello_timeout_usec | ( | long long | _hello_timeout_usec | ) | [inline] |
References hello_timeout_usec.
void libt2n::ConnectionWrapper::set_logging | ( | std::ostream * | _logstream, | |
log_level_values | _log_level | |||
) | [virtual] |
activate logging to the given stream. everything above the given level is logged.
Reimplemented in libt2n::BasicSocketWrapper.
void libt2n::ConnectionWrapper::set_logging_on_connection | ( | client_connection & | c | ) | [protected] |
always call this when you got a new connection to transfer logging settings
References log_level, logstream, libt2n::none, and libt2n::client_connection::set_logging().
long long libt2n::ConnectionWrapper::command_timeout_usec [private] |
Referenced by get_command_timeout_usec(), and set_command_timeout_usec().
long long libt2n::ConnectionWrapper::hello_timeout_usec [private] |
Referenced by get_hello_timeout_usec(), and set_hello_timeout_usec().
log_level_values libt2n::ConnectionWrapper::log_level [protected] |
Referenced by libt2n::BasicSocketWrapper::get_connection(), get_logstream(), set_logging(), and set_logging_on_connection().
std::ostream* libt2n::ConnectionWrapper::logstream [protected] |
Referenced by libt2n::BasicSocketWrapper::get_connection(), get_logstream(), set_logging(), and set_logging_on_connection().