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

msg_cpp Class Reference

message class internal message representation More...

#include <msg_cpp.h>

Inheritance diagram for msg_cpp:

msg_t

List of all members.

Public Member Functions

void pack_msg (const room_byte_t *key)
 packs message prepares block - continuant part of message for block sending
void unpack_msg (const room_byte_t *key)
 unpacks message fill msg_cpp fields taking information from block part
bool resize (size_t size_)
 resizes body size save previous part, if any
size_t get_size () const
 returns the body size
const ub1_tget_body () const
 returns pointer to body - read only
ub1_tget_body ()
 returns pointer to body - writable version
const ub1_tget_block () const
 returns pointer to block - read only
ub1_tget_block ()
 returna pointer to block - writable version

Static Public Member Functions

static msg_cppconstruct (byte_allocator *allocator_, size_t size_)
 "static" constructor
static byte_allocatordestroy (msg_cpp *msg)
 "static" destructor
static size_t estimate_size (size_t size_)
 estimates the size of whole message with body size
static size_t crypt_size (size_t size_)
 culculate crypt size
static size_t block_size (size_t size_)
 returns the block size for body size
static ub4_t reverse32 (ub4_t value)
 network byte order 4 bytes
static ub2_t reverse16 (ub2_t value)
 network byte order 2 bytes
static size_t pack32 (ub1_t *&dest, ub4_t x)
 copies 4 bytes to the buffer in network format and move pointer to the buffer
static size_t unpack32 (const ub1_t *&x, ub4_t &dest)
 copies 4 bytes from the buffer in host format and move pointer to the buffer
static size_t pack16 (ub1_t *&dest, ub2_t x)
 copies 2 bytes to the buffer in network format and move pointer to the buffer
static size_t unpack16 (const ub1_t *&x, ub2_t &dest)
 copies 2 bytes from the buffer in host format and move pointer to the buffer
static size_t packaddr (ub1_t *&dest, const guid_t &x)
 copies 32 bytes (GUID format) to the buffer in network format and move pointer to the buffer
static size_t unpackaddr (const ub1_t *&x, guid_t &dest)
 copies 32 bytes (GUID format) from the buffer in host format and move pointer to the buffer
static size_t pack64 (ub1_t *&dest, const ub8_t &x)
 copies 8 bytes (double format) to the buffer in network format and move pointer to the buffer
static size_t unpack64 (const ub1_t *&x, ub8_t &dest)
 copies 8 bytes (double format) from the buffer in host format and move pointer to the buffer

Public Attributes

ub4_t _type
 type of message (system, handshake, user ...)
guid_t _marker
 marker for identification of the reply message
sb8_t _timestamp
 date&time of message
guid_t _sender
 message sender
guid_t _receiver
 message receiver
guid_t _sessionid
 connection session identificator

Private Member Functions

 msg_cpp (byte_allocator *allocator_, size_t size_)
 hidden constructor
virtual ~msg_cpp ()
 hidden destructor

Static Private Member Functions

static size_t _block_body_offset ()
 returns the offset of body from the begining of the msg_cpp class instance

Private Attributes

ub4_t _size
 size of message body
byte_allocator_allocator
 pointer to allocator
ub1_t_body
 poiter to message body
ub1_t_block
 pointer to the block


Detailed Description

message class internal message representation

Definition at line 97 of file msg_cpp.h.


Constructor & Destructor Documentation

msg_cpp::msg_cpp ( byte_allocator allocator_,
size_t  size_ 
) [private]

msg_cpp::~msg_cpp (  )  [private, virtual]

hidden destructor

Definition at line 69 of file msg_cpp.cpp.

Referenced by destroy().


Member Function Documentation

static msg_cpp* msg_cpp::construct ( byte_allocator allocator_,
size_t  size_ 
) [inline, static]

"static" constructor

Parameters:
allocator_  external allocator
size_  message size

Definition at line 108 of file msg_cpp.h.

References byte_allocator::allocate(), and msg_cpp().

Referenced by msg_communicator::construct_msg().

static byte_allocator* msg_cpp::destroy ( msg_cpp msg  )  [inline, static]

"static" destructor

Parameters:
msg  message pointer

Definition at line 128 of file msg_cpp.h.

References _allocator, and ~msg_cpp().

Referenced by msg_communicator::destroy_msg().

void msg_cpp::pack_msg ( const room_byte_t key  ) 

packs message prepares block - continuant part of message for block sending

Parameters:
key  private symmetric key, optional

Definition at line 74 of file msg_cpp.cpp.

References _block, _body, _marker, _receiver, _sender, _sessionid, _size, _timestamp, _type, msg_t::majver, msg_t::minver, msg_t::msgid, pack32(), pack64(), packaddr(), msg_t::priority, room_array< T >::size(), and msg_t::timeout.

Referenced by msg_rpc_connection::send_msg(), and msg_sock_connection::v_do_job().

void msg_cpp::unpack_msg ( const room_byte_t key  ) 

bool msg_cpp::resize ( size_t  size_  ) 

resizes body size save previous part, if any

Parameters:
size_  message size

Definition at line 168 of file msg_cpp.cpp.

References _allocator, _block, _block_body_offset(), _body, _size, byte_allocator::allocate(), block_size(), and pack32().

Referenced by msg_pack::make_error_msg(), msg_cpp(), and msg_communicator::resize_msg().

size_t msg_cpp::get_size (  )  const [inline]

ub1_t* msg_cpp::get_body (  )  [inline]

returns pointer to body - writable version

Definition at line 172 of file msg_cpp.h.

References _body.

const ub1_t* msg_cpp::get_block (  )  const [inline]

returns pointer to block - read only

Definition at line 179 of file msg_cpp.h.

References _block.

Referenced by msg_rpc_connection::send_msg(), msg_sock_connection::v_do_job(), msg_sock_connection::v_on_receive(), and msg_sock_connection::v_on_send().

ub1_t* msg_cpp::get_block (  )  [inline]

returna pointer to block - writable version

Definition at line 186 of file msg_cpp.h.

References _block.

static size_t msg_cpp::estimate_size ( size_t  size_  )  [inline, static]

estimates the size of whole message with body size

Parameters:
size_  message size

Definition at line 194 of file msg_cpp.h.

References block_size().

Referenced by msg_communicator::construct_msg().

static size_t msg_cpp::crypt_size ( size_t  size_  )  [inline, static]

culculate crypt size

Parameters:
size_  input bytes to crypt

Definition at line 203 of file msg_cpp.h.

References ALIGNED_MASK_SIZEOF, and msg_crypt_block.

Referenced by block_size(), and unpack_msg().

static size_t msg_cpp::block_size ( size_t  size_  )  [inline, static]

returns the block size for body size

Parameters:
size_  message size

Definition at line 212 of file msg_cpp.h.

References _block_body_offset(), and crypt_size().

Referenced by msg_rpc_connection::connect(), estimate_size(), resize(), ServerConnect(), ServerPostBlock(), unpack_msg(), and msg_sock_connection::v_on_receive().

static size_t msg_cpp::_block_body_offset (  )  [inline, static, private]

returns the offset of body from the begining of the msg_cpp class instance

Definition at line 222 of file msg_cpp.h.

Referenced by block_size(), resize(), and unpack_msg().

static ub4_t msg_cpp::reverse32 ( ub4_t  value  )  [inline, static]

network byte order 4 bytes

Parameters:
value  input value

Definition at line 237 of file msg_cpp.h.

static ub2_t msg_cpp::reverse16 ( ub2_t  value  )  [inline, static]

network byte order 2 bytes

Parameters:
value  input value

Definition at line 247 of file msg_cpp.h.

static size_t msg_cpp::pack32 ( ub1_t *&  dest,
ub4_t  x 
) [inline, static]

copies 4 bytes to the buffer in network format and move pointer to the buffer

Parameters:
dest  buffer pointer
x  input value

Definition at line 258 of file msg_cpp.h.

Referenced by pack_msg(), packaddr(), and resize().

static size_t msg_cpp::unpack32 ( const ub1_t *&  x,
ub4_t dest 
) [inline, static]

copies 4 bytes from the buffer in host format and move pointer to the buffer

Parameters:
x  input buffer pointer
dest  [out] value

Definition at line 272 of file msg_cpp.h.

Referenced by unpack_msg(), and unpackaddr().

static size_t msg_cpp::pack16 ( ub1_t *&  dest,
ub2_t  x 
) [inline, static]

copies 2 bytes to the buffer in network format and move pointer to the buffer

Parameters:
dest  output buffer pointer
x  input value

Definition at line 287 of file msg_cpp.h.

Referenced by packaddr().

static size_t msg_cpp::unpack16 ( const ub1_t *&  x,
ub2_t dest 
) [inline, static]

copies 2 bytes from the buffer in host format and move pointer to the buffer

Parameters:
x  input buffer pointer
dest  [out] value

Definition at line 302 of file msg_cpp.h.

Referenced by unpackaddr().

static size_t msg_cpp::packaddr ( ub1_t *&  dest,
const guid_t x 
) [inline, static]

copies 32 bytes (GUID format) to the buffer in network format and move pointer to the buffer

Parameters:
dest  output buffer pointer
x  input value

Definition at line 317 of file msg_cpp.h.

References _terimber_guid_::Data1, _terimber_guid_::Data2, _terimber_guid_::Data3, _terimber_guid_::Data4, pack16(), and pack32().

Referenced by pack_msg().

static size_t msg_cpp::unpackaddr ( const ub1_t *&  x,
guid_t dest 
) [inline, static]

copies 32 bytes (GUID format) from the buffer in host format and move pointer to the buffer

Parameters:
x  input buffer pointer
dest  [out] value

Definition at line 336 of file msg_cpp.h.

References _terimber_guid_::Data1, _terimber_guid_::Data2, _terimber_guid_::Data3, _terimber_guid_::Data4, unpack16(), and unpack32().

Referenced by unpack_msg().

static size_t msg_cpp::pack64 ( ub1_t *&  dest,
const ub8_t x 
) [inline, static]

copies 8 bytes (double format) to the buffer in network format and move pointer to the buffer

Parameters:
dest  output buffer pointer
x  input value

Definition at line 355 of file msg_cpp.h.

Referenced by pack_msg().

static size_t msg_cpp::unpack64 ( const ub1_t *&  x,
ub8_t dest 
) [inline, static]

copies 8 bytes (double format) from the buffer in host format and move pointer to the buffer

Parameters:
x  input buffer pointer
dest  [out] value

Definition at line 371 of file msg_cpp.h.

Referenced by unpack_msg().


Member Data Documentation

marker for identification of the reply message

Definition at line 383 of file msg_cpp.h.

Referenced by msg_pack::make_reply_msg(), pack_msg(), msg_user_connection::push_msg(), and unpack_msg().

ub4_t msg_cpp::_size [private]

size of message body

Definition at line 389 of file msg_cpp.h.

Referenced by get_size(), pack_msg(), resize(), and unpack_msg().

pointer to allocator

Definition at line 390 of file msg_cpp.h.

Referenced by destroy(), msg_cpp(), and resize().

ub1_t* msg_cpp::_body [private]

poiter to message body

Definition at line 391 of file msg_cpp.h.

Referenced by get_body(), pack_msg(), resize(), and unpack_msg().

ub1_t* msg_cpp::_block [private]

pointer to the block

Definition at line 392 of file msg_cpp.h.

Referenced by get_block(), pack_msg(), resize(), and unpack_msg().


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


© Copyright Terimber 2003-.