S3FC project page | S3FC home page |
T_obj
instance.
More...
#include <s3_rpc.h>
Inheritance diagram for s3_rpc_server:
Public Methods | |
s3_rpc_server (const std::string &n_name, T_obj &n_obj) | |
Initialising constructor: Instantiate an RPC server that controls a single T_obj instance, setting its name, target instance and callmap. More... | |
virtual | ~s3_rpc_server () |
Destructor: disconnect from the postal system and clean up. More... | |
Protected Methods | |
virtual void | main_loop () |
Function that is invoked as the main loop in its own thread. More... | |
void | handle_message (const s3_message &msg) |
void | exec_cmd_call (const s3_message &msg, std::string body_str) |
std::string | remove_first (std::string &str) |
Static Protected Methods | |
void | reply_client (s3_message_box &mb, const s3_message &msg, const std::string &err, bool err) |
Protected Attributes | |
s3_message_box | mb |
Message box that receives RPC requests relating to obj . More... | |
T_obj * | obj |
Pointer to T_obj instance on which this serves invokes methods. More... | |
s3_rpc_type_common< T_obj >::callmap_t | cmap |
Map between function names and callers that invoke the functions. More... | |
s3_semaphore | started |
T_obj
instance.
Each server has a name string and allows named methods of the T_obj
instance to be remotely invoked from an s3_rpc_client
. Each method of T_obj
that should be remotely invoked are provided with a name string. In order to invoke a method on an instance, the client requires the name of the RPC server controlling the as well as the name of the method to invoke.
The RPC system uses the Stone Three Postal System and all clients and servers wishing to interact using RPC should use the same postal system (i.e. they should all invoke s3_message_box::init()
with the same arguments in all process spaces). The name assigned to an s3_rpc_server
should be unique within all other RPC servers using the same postal system, as each RPC server contains a message box with a name that is derived from the RPC server name.
Mapping a method name to a member function is done by the callmap, which associates the name string of the method with a dispatcher instance that invokes it. The RPC server obtains this callmap by calling the following method:
* static s3_rpc_server<T_obj>::callmap_t s3_rpc_callmap<T_obj>::value() *
s3_rpc_callmap
should therefore be specialised for each T_obj
type that should be controllable using RPC.
Definition at line 254 of file s3_rpc.h.
|
Initialising constructor: Instantiate an RPC server that controls a single
Definition at line 150 of file s3_rpc.tcc. References s3_message_box::connect, mb, s3_rpc_common::rpc_server_name, s3_message_box::set_name, s3_thread_base::start, started, and s3_semaphore::wait. |
|
Destructor: disconnect from the postal system and clean up.
Definition at line 178 of file s3_rpc.tcc. References s3_rpc_type_common::clear_callmap, cmap, s3_message_box::disconnect, mb, s3_thread_base::request_terminate, and s3_thread_base::wait_on_exit. |
|
Definition at line 245 of file s3_rpc.tcc. References cmap, mb, obj, remove_first, reply_client, and s3_conversion::split_string. Referenced by handle_message. |
|
Definition at line 209 of file s3_rpc.tcc. References s3_rpc_common::cmd_tag_call, exec_cmd_call, s3_message::get_body, s3_message::is_empty, mb, remove_first, and reply_client. Referenced by main_loop. |
|
Function that is invoked as the main loop in its own thread. Override this in derived class.
Implements s3_thread_base. Definition at line 190 of file s3_rpc.tcc. References s3_message_box::get_msg, handle_message, mb, s3_semaphore::post, S3FC_DBG, started, s3_thread_base::state_changed, s3_message_box::subscribe_arrival, s3_thread_base::test_terminate, and s3_thread_base::wait_on_state_changed. |
|
Definition at line 286 of file s3_rpc.tcc. Referenced by exec_cmd_call, and handle_message. |
|
Definition at line 312 of file s3_rpc.tcc. References s3_message::get_body, s3_message::get_from, s3_message_box::reply_msg, and S3FC_DBG. Referenced by exec_cmd_call, and handle_message. |
|
Map between function names and callers that invoke the functions.
Definition at line 268 of file s3_rpc.h. Referenced by exec_cmd_call, and ~s3_rpc_server. |
|
Message box that receives RPC requests relating to
Definition at line 260 of file s3_rpc.h. Referenced by exec_cmd_call, handle_message, main_loop, s3_rpc_server, and ~s3_rpc_server. |
|
Pointer to
Definition at line 264 of file s3_rpc.h. Referenced by exec_cmd_call. |
|
Reimplemented from s3_thread_base. Definition at line 270 of file s3_rpc.h. Referenced by main_loop, and s3_rpc_server. |
Send comments to: s3fc@stonethree.com |
|