Thread portable class


Gate portable class


Timer class


Pool class


Terimber 2.0


About C++


Downloads Products & Services Support Clients Open Source About



Home / Open source / Terimber 2.0

aiomsg Class Reference

implements terimber_aiomsg interface More...

#include <msgimpl.h>

Inheritance diagram for aiomsg:

terimber_aiomsg terimber_log_helper terimber_log

List of all members.

Public Member Functions

 aiomsg ()
 constructor
virtual ~aiomsg ()
 destructor
virtual bool init (const char *info, const char *ini_key)
 initial functions to activate and deactivate message transport
virtual bool init (const void *buffer, size_t len)
 initial functions to activate and deactivate message transport
virtual bool uninit ()
 function uninitializes the message port
virtual bool start (msg_callback_notify *callback, size_t additional_thread_count)
 function for activate and deactivate callback port it make sense to specify additional_thread_count > 0 if the order incoming messages doesn't matter otherwise specify additional_thread_count = 0 and process incoming messages one by one in order as they arrived
virtual bool stop ()
 function stops message processing
virtual const char * get_port_error () const
 messages port error function
virtual const guid_tget_port_address () const
 returns the port address - comes from init file
virtual msg_tconstruct (size_t size)
 internal allocate, reallocate, and free memory caller has to create ALL messages through construct function and call destroy function to free memory returns pointer to the message object or null
virtual bool resize (msg_t *msg, size_t size)
 resizes the message the old memory will be preserved
virtual bool destroy (msg_t *msg)
 destroys message
virtual size_t get_size (const msg_t *msg) const
 messages content management functions function returns the message size
virtual bool write_buffer (msg_t *msg, size_t offset, const void *buf, size_t len)
 function returns true if offset + len <= message size (see resize function)
virtual const void * get_buffer (const msg_t *msg) const
 constant variant of previous function
virtual bool set_receiver (msg_t *msg, const guid_t &receiver)
 messages from/to settings
virtual bool get_sender (const msg_t *msg, guid_t &sender) const
 gets sender address
virtual bool send (bool copy, msg_t *msg, msg_t **reply)
 function sends message and waits for the reply for timeout milliseconds (garantee delivery) if function returns false the caller is still responsible for message destruction regardless the copy parameter value
virtual guid_t send_async (bool copy, msg_t *msg)
 function sends message asynchronically (garantee delivery) and returns unique identificator (zero means error) which will be used as input parameter for asynchronous callback function if function returns zero the caller is still responsible for message destruction regardless the copy parameter value retun value, if non zero is unique identificator, which will be used for firing asynchronous reply, see above
virtual bool post (bool copy, msg_t *msg)
 function post message and don't wait for a reply - this is a non-garantee delivery if function returns false the caller is still responsible for message destruction regardless the copy parameter value
virtual bool add_connection (const char *xml_description)
 additional functionality to manage connections dynamically - xml string describes connection as xml node of follow XDTD extended DTD <!ENTITY % kind "(rpc | sock | p2p)"> <!ELEMENT connection EMPTY> <!ATTLIST connection address CTYPE vt_guid REQUIRED port CTYPE vt_ub2 IMPLIED network CDATA IMPLIED ping CTYPE vt_ub4 IMPLIED info CDATA IMPLIED security CTYPE vt_bool IMPLIED password CDATA IMPLIED > encpytion is reserved for production version
virtual bool add_listener (const char *xml_description)
 additional functionality to manage listeners dynamically extended DTD <!ELEMENT listener (accept | reject)?> <!ELEMENT reject (peer)+> <!ELEMENT accept (peer)+> <!ELEMENT peer EMPTY> <!ATTLIST peer address CTYPE vt_guid REQUIRED security CTYPE vt_bool IMPLIED password CDATA IMPLIED > <!ATTLIST listener port CTYPE vt_ub2 IMPLIED network CDATA IMPLIED connections CTYPE vt_ub4 IMPLIED ping CTYPE vt_ub4 IMPLIED waste CTYPE vt_ub4 IMPLIED info CDATA IMPLIED security CTYPE vt_bool IMPLIED password CDATA IMPLIED >
virtual bool remove_connection (const guid_t &address)
 removes connection dynamically
virtual bool remove_listener (const char *type)
 removes listener dynamically
virtual void doxray ()
 do xray

Private Member Functions

void check_on () const
 checks if communicator is on NB!!! throws exception
void check_ident () const
 checks validity of user connection NB!!! throws exception

Private Attributes

msg_communicator _communicator
 messages communicator
string_t _error
 last error
mutex _mtx
 mutex
msg_user_connection_user_conn
 pointer to user connection


Detailed Description

implements terimber_aiomsg interface

Definition at line 40 of file msgimpl.h.


Constructor & Destructor Documentation

BEGIN_TERIMBER_NAMESPACE aiomsg::aiomsg (  ) 

constructor

Definition at line 101 of file msgimpl.cpp.

aiomsg::~aiomsg (  )  [virtual]

destructor

Definition at line 106 of file msgimpl.cpp.

References stop().


Member Function Documentation

bool aiomsg::init ( const char *  info,
const char *  ini_key 
) [virtual]

initial functions to activate and deactivate message transport

Parameters:
info  a full path to the ini xml file with port initialization information
ini_key  crypto key for decription ini xml file - reserved for production version

Implements terimber_aiomsg.

Definition at line 112 of file msgimpl.cpp.

References _communicator, _error, _mtx, and msg_communicator::init().

bool aiomsg::init ( const void *  buffer,
size_t  len 
) [virtual]

initial functions to activate and deactivate message transport

Parameters:
buffer  a pointer to xml memory
len  parameter is a length of xml in memory

Implements terimber_aiomsg.

Definition at line 129 of file msgimpl.cpp.

References _communicator, _error, _mtx, msg_communicator::init(), and terimber_log_helper::log_on().

bool aiomsg::uninit (  )  [virtual]

function uninitializes the message port

Implements terimber_aiomsg.

Definition at line 150 of file msgimpl.cpp.

References _communicator, _error, _mtx, terimber_log_helper::log_on(), stop(), and msg_communicator::uninit().

bool aiomsg::start ( msg_callback_notify callback,
size_t  additional_thread_count 
) [virtual]

function for activate and deactivate callback port it make sense to specify additional_thread_count > 0 if the order incoming messages doesn't matter otherwise specify additional_thread_count = 0 and process incoming messages one by one in order as they arrived

Parameters:
callback  pointer to the callback class instance
additional_thread_count  user defines how many threads can call incoming callback function at the same time

Implements terimber_aiomsg.

Definition at line 169 of file msgimpl.cpp.

References conf_connection::_address, _communicator, _error, _mtx, conf_connection::_ping, _user_conn, check_on(), msg_user_connection::connect(), msg_communicator::get_address(), msg_base::on(), and stop().

bool aiomsg::stop (  )  [virtual]

function stops message processing

Implements terimber_aiomsg.

Definition at line 193 of file msgimpl.cpp.

References _communicator, _error, _mtx, _user_conn, msg_base::off(), and msg_communicator::shutdown_connection().

Referenced by start(), uninit(), and ~aiomsg().

const char * aiomsg::get_port_error (  )  const [virtual]

messages port error function

port error function

Implements terimber_aiomsg.

Definition at line 219 of file msgimpl.cpp.

References _error.

const guid_t & aiomsg::get_port_address (  )  const [virtual]

returns the port address - comes from init file

Implements terimber_aiomsg.

Definition at line 225 of file msgimpl.cpp.

References _communicator, and msg_communicator::get_address().

msg_t * aiomsg::construct ( size_t  size  )  [virtual]

internal allocate, reallocate, and free memory caller has to create ALL messages through construct function and call destroy function to free memory returns pointer to the message object or null

Parameters:
size  size of message in bytes

Implements terimber_aiomsg.

Definition at line 231 of file msgimpl.cpp.

References _communicator, _error, _mtx, check_on(), and msg_communicator::construct_msg().

bool aiomsg::resize ( msg_t msg,
size_t  size 
) [virtual]

resizes the message the old memory will be preserved

Parameters:
msg  pointer to the message to be resized
size  new size of message in bytes

Implements terimber_aiomsg.

Definition at line 247 of file msgimpl.cpp.

References _communicator, _error, _mtx, msg_communicator::cast(), check_on(), and msg_communicator::resize_msg().

bool aiomsg::destroy ( msg_t msg  )  [virtual]

destroys message

Parameters:
msg  pointer to the message to be destroyed

Implements terimber_aiomsg.

Definition at line 263 of file msgimpl.cpp.

References _communicator, _error, _mtx, msg_communicator::cast(), check_on(), and msg_communicator::destroy_msg().

size_t aiomsg::get_size ( const msg_t msg  )  const [virtual]

messages content management functions function returns the message size

Parameters:
msg  pointer to the message

Implements terimber_aiomsg.

Definition at line 279 of file msgimpl.cpp.

References _error, _mtx, msg_communicator::cast(), check_on(), and msg_cpp::get_size().

bool aiomsg::write_buffer ( msg_t msg,
size_t  offset,
const void *  buf,
size_t  len 
) [virtual]

function returns true if offset + len <= message size (see resize function)

Parameters:
msg  pointer to the message
offset  offset from the beginning of message body
buf  pointer to the buffer
len  length of writing buffer

Implements terimber_aiomsg.

Definition at line 296 of file msgimpl.cpp.

References _error, _mtx, msg_communicator::cast(), check_on(), msg_cpp::get_body(), and msg_cpp::get_size().

const void * aiomsg::get_buffer ( const msg_t msg  )  const [virtual]

constant variant of previous function

Parameters:
msg  pointer to the constant message

Implements terimber_aiomsg.

Definition at line 317 of file msgimpl.cpp.

References _error, _mtx, msg_communicator::cast(), check_on(), and msg_cpp::get_body().

bool aiomsg::set_receiver ( msg_t msg,
const guid_t receiver 
) [virtual]

messages from/to settings

Parameters:
msg  pointer to the message
receiver  reference to receiver address

Implements terimber_aiomsg.

Definition at line 334 of file msgimpl.cpp.

References _error, _mtx, msg_communicator::cast(), check_on(), and msg_communicator::set_receiver().

bool aiomsg::get_sender ( const msg_t msg,
guid_t sender 
) const [virtual]

gets sender address

Parameters:
msg  pointer to the message
sender  reference where function put sender address to

Implements terimber_aiomsg.

Definition at line 350 of file msgimpl.cpp.

References _error, _mtx, msg_communicator::cast(), check_on(), and msg_communicator::get_sender().

bool aiomsg::send ( bool  copy,
msg_t msg,
msg_t **  reply 
) [virtual]

function sends message and waits for the reply for timeout milliseconds (garantee delivery) if function returns false the caller is still responsible for message destruction regardless the copy parameter value

Transport functions

Parameters:
copy  if set to true, the function will make a copy of the message and caller can reuse message again
msg  otherwise message port will take care about it pointer to message to be sent, if function returns true and copy == false then message port is responsible for message destruction
reply  returns the reply from receiver, caller is responsible to destroy the reply message

Implements terimber_aiomsg.

Definition at line 366 of file msgimpl.cpp.

References _communicator, _error, _mtx, _user_conn, msg_communicator::cast(), check_ident(), check_on(), msg_communicator::destroy_msg(), msg_user_connection::get_last_error(), and msg_user_connection::send().

guid_t aiomsg::send_async ( bool  copy,
msg_t msg 
) [virtual]

function sends message asynchronically (garantee delivery) and returns unique identificator (zero means error) which will be used as input parameter for asynchronous callback function if function returns zero the caller is still responsible for message destruction regardless the copy parameter value retun value, if non zero is unique identificator, which will be used for firing asynchronous reply, see above

Parameters:
copy  if set to true, the function will make a copy of the message and caller can reuse message again
msg  otherwise message port will take care about it pointer to message to be sent, if function returns true and copy == false then message port is responsible for message destruction

Implements terimber_aiomsg.

Definition at line 395 of file msgimpl.cpp.

References _communicator, _error, _mtx, _user_conn, msg_communicator::cast(), check_ident(), check_on(), msg_user_connection::get_last_error(), null_uuid, and msg_user_connection::send_async().

bool aiomsg::post ( bool  copy,
msg_t msg 
) [virtual]

function post message and don't wait for a reply - this is a non-garantee delivery if function returns false the caller is still responsible for message destruction regardless the copy parameter value

Parameters:
copy  if set to true, the function will make a copy of the message and caller can reuse message again
msg  pointer to message to be sent, if function returns true and copy == false then message port is responsible for message destruction otherwise message port will take care about it

Implements terimber_aiomsg.

Definition at line 416 of file msgimpl.cpp.

References _error, _mtx, _user_conn, msg_communicator::cast(), check_ident(), check_on(), msg_user_connection::get_last_error(), and msg_user_connection::post().

bool aiomsg::add_connection ( const char *  xml_description  )  [virtual]

additional functionality to manage connections dynamically - xml string describes connection as xml node of follow XDTD extended DTD <!ENTITY % kind "(rpc | sock | p2p)"> <!ELEMENT connection EMPTY> <!ATTLIST connection address CTYPE vt_guid REQUIRED port CTYPE vt_ub2 IMPLIED network CDATA IMPLIED ping CTYPE vt_ub4 IMPLIED info CDATA IMPLIED security CTYPE vt_bool IMPLIED password CDATA IMPLIED > encpytion is reserved for production version

Implements terimber_aiomsg.

Definition at line 437 of file msgimpl.cpp.

References _communicator, _error, _mtx, msg_communicator::add_connection_config(), check_on(), msg_connection_dtd, msg_communicator::parse_connection(), and str_template::strlen().

bool aiomsg::add_listener ( const char *  xml_description  )  [virtual]

additional functionality to manage listeners dynamically extended DTD <!ELEMENT listener (accept | reject)?> <!ELEMENT reject (peer)+> <!ELEMENT accept (peer)+> <!ELEMENT peer EMPTY> <!ATTLIST peer address CTYPE vt_guid REQUIRED security CTYPE vt_bool IMPLIED password CDATA IMPLIED > <!ATTLIST listener port CTYPE vt_ub2 IMPLIED network CDATA IMPLIED connections CTYPE vt_ub4 IMPLIED ping CTYPE vt_ub4 IMPLIED waste CTYPE vt_ub4 IMPLIED info CDATA IMPLIED security CTYPE vt_bool IMPLIED password CDATA IMPLIED >

Implements terimber_aiomsg.

Definition at line 477 of file msgimpl.cpp.

References _communicator, _error, _mtx, msg_communicator::add_listener_config(), check_on(), msg_listener_dtd, msg_communicator::parse_listener(), and str_template::strlen().

bool aiomsg::remove_connection ( const guid_t address  )  [virtual]

removes connection dynamically

Parameters:
address  address of connection

Implements terimber_aiomsg.

Definition at line 521 of file msgimpl.cpp.

References _communicator, _error, _mtx, check_on(), and msg_communicator::remove_connection_config().

bool aiomsg::remove_listener ( const char *  type  )  [virtual]

removes listener dynamically

Parameters:
type  type of listener (sock)

Implements terimber_aiomsg.

Definition at line 540 of file msgimpl.cpp.

References _communicator, _error, _mtx, check_on(), msg_communicator::remove_listener_config(), and sock.

void aiomsg::doxray (  )  [virtual]

do xray

does xray

Implements terimber_aiomsg.

Definition at line 581 of file msgimpl.cpp.

References _communicator, and msg_communicator::doxray().

void aiomsg::check_on (  )  const [private]

void aiomsg::check_ident (  )  const [private]

checks validity of user connection NB!!! throws exception

Definition at line 572 of file msgimpl.cpp.

References _communicator, _user_conn, and msg_communicator::validate_connection().

Referenced by post(), send(), and send_async().


Member Data Documentation

pointer to user connection

Definition at line 251 of file msgimpl.h.

Referenced by check_ident(), post(), send(), send_async(), start(), and stop().


The documentation for this class was generated from the following files:


© Copyright Terimber 2003-.