Public Types
Tonido::Data::Message Class Reference

Unit of all communication within and between peers. More...

List of all members.

Public Types

typedef boost::shared_ptr
< Message
SharedPtr

Public Member Functions

Ctors & Dtors
 Message ()
 Default contructor.
 Message (Message &a_Message)
 Copy constructor.
 Message (const std::string &a_fromService, const std::string &a_toService, const std::string &a_operation)
 Constructor to initialize header.
 Message (uint8_bt *a_buffer, uint64_bt a_buflen)
 Constructor for un-serialization.
virtual ~Message ()
 Destructor.
Serialization Functions
void flatten (Data::RawData::SharedPtr &a_data)
 Serialize message to a RawData block.
Operators
Messageoperator= (Message &a_message)
 Assignment operator.
Data::VariantRowoperator[] (const std::string &a_index)
 operator[]
Setters & Getters
const std::string & getFromService () const
 Returns which service sent this messsage.
void setFromService (const std::string &a_fromService)
 Set the caller service of this message.
const Tonido::Data::PeerIDgetToPeerID (void) const
 Gets to whom the message is being sent to.
void setToPeerID (const Tonido::Data::PeerID &a_toPeerID)
 Sets to whom the message is being sent to.
const Tonido::Data::PeerIDgetFromPeerID (void) const
 Gets the PeerID who sent this message.
void setFromPeerID (const Tonido::Data::PeerID &a_fromPeerID)
 Sets the PeerID from whom this message comes from.
const std::string & getVersion (void) const
 Gets the Message Version.
const std::string & getToService (void) const
 Gets to whom the message is going to.
void setToService (const std::string &a_toService)
 Sets to whom the message is going to.
uint32_bt getFlags (void) const
 Returns the message flags of this message.
void setFlags (uint16_bt a_flags)
 Sets the message flag of this message.
const std::string & getOperation (void) const
 Get Operation of this message.
void setOperation (const std::string &a_operation)
 Sets the Operation of this message.
uint32_bt getSeqNumber (void) const
 Monotically increasing sequence number for this message.
void setRawData (const char *i_Buffer, uint64_bt i_BufferLength)
 Sets the payload that is part of this message.
void setRawData (const Data::RawData::SharedPtr &a_rawData)
 Sets the payload that is part of this message.
uint64_bt getRawDataLen (void) const
 Get raw data length in message object.
uint8_bt * getRawData (void) const
 Get raw data stored in message object.
uint64_bt messageLength (void)
 Get Message length.
Data::VariantTablegetVariantTable ()
 Returns the variant table associated with this message.
const AuthKeygetAuthKey ()
 Returns the Auth Key associated with this message.
void setAuthKey (const AuthKey &a_authKey)
 Sets the Auth Key associated with this message.
void setCount (uint32_bt a_count)
 Setters and Getters for Utility Counters.
uint32_bt getCount () const

Detailed Description

Unit of all communication within and between peers.

  The following is message serialization format in memory

      0 +------------------------------------+
        |      EyeCatcher#1 (0xBEEFCODE)     |
      4 +------------------------------------+
        |           Version                  |
      8 +------------------------------------+
        |           Flags                    |
     12 +------------------------------------+
        |         Sequence #                 |
     16 +------------------------------------+
        |         Reserved                   |
     20 +------------------------------------+
        |      From Service Length           |
     24 +------------------------------------+
        |      From Service Data(*)          |
     x  +------------------------------------+
        |      To Service Length             |
     +4 +------------------------------------+
        |      To Service Data(*)            |
     x  +------------------------------------+
        |      From PeerID(*)                |
     x  +------------------------------------+
        |      To PeerID(*)                  |
     x  +------------------------------------+
        |      Operation Data Length         |
     +4 +------------------------------------+           .
        |      Operation Data(*)             |
     +4 +------------------------------------+
        |      Raw Data Length               |
    +12 +------------------------------------+
        |      Fn Map Raw Data Length        |
    +16 +------------------------------------+
        |      Raw Data (*)                  |
     x  +------------------------------------+
        |      EyeCatcher#2(0xDEADC0DE)      |
     +4 +------------------------------------+
        |      Fn Map Raw Data(*)            |
     x  +------------------------------------+
        |      EyeCatcher#3(0xC0DEDEAD)      |
     +4 +------------------------------------+

Constructor & Destructor Documentation

Tonido::Message::Message ( )

Default contructor.

Just create object with no data

Tonido::Data::Message::Message ( Message a_Message)

Copy constructor.

Create a new object from another message object

Tonido::Message::Message ( const std::string &  a_fromService,
const std::string &  a_toService,
const std::string &  a_operation 
)

Constructor to initialize header.

Create a new message with header filled in but without a data

Tonido::Message::Message ( uint8_bt *  a_buffer,
uint64_bt  a_buflen 
)

Constructor for un-serialization.

Create a Message object from a serialized buffer

Tonido::Message::~Message ( ) [virtual]

Destructor.

Destructor that will delete m_pRawDataBuf, m_pRawDataBuf, m_pTraceBuf


Member Function Documentation

void Tonido::Message::flatten ( Data::RawData::SharedPtr &  a_data)

Serialize message to a RawData block.

the buffer must be allocated to hold message.

const Tonido::Data::PeerID& Tonido::Data::Message::getFromPeerID ( void  ) const

Gets the PeerID who sent this message.

Returns:
the caller ID of this message
const std::string& Tonido::Data::Message::getFromService ( ) const

Returns which service sent this messsage.

Returns:
returns the caller service of this message
const std::string& Tonido::Data::Message::getOperation ( void  ) const

Get Operation of this message.

Returns:
the operation value of this message
uint8_bt* Tonido::Data::Message::getRawData ( void  ) const

Get raw data stored in message object.

Return pointer to the raw data stored

uint64_bt Tonido::Data::Message::getRawDataLen ( void  ) const

Get raw data length in message object.

Return raw data length

uint32_bt Tonido::Data::Message::getSeqNumber ( void  ) const

Monotically increasing sequence number for this message.

return the seq number value of this message

const Tonido::Data::PeerID& Tonido::Data::Message::getToPeerID ( void  ) const

Gets to whom the message is being sent to.

Note that for local messaging, you don't need to set the to peer id

Returns:
the PeerID to whom this message is being sent
const std::string& Tonido::Data::Message::getVersion ( void  ) const

Gets the Message Version.

Note: The format of the message is of the form major.minor.patch.revision

uint64_bt Tonido::Message::messageLength ( void  )

Get Message length.

Calculate header + data length

Message& Tonido::Data::Message::operator= ( Message a_message)

Assignment operator.

The message passed in will be replicated and the a reference will be returned

Data::VariantRow& Tonido::Data::Message::operator[] ( const std::string &  a_index)

operator[]

Accesses the appropriate message section

Parameters:
[in]a_indexof the message section to access
Returns:
VariantRow in that section
void Tonido::Data::Message::setFromPeerID ( const Tonido::Data::PeerID a_fromPeerID)

Sets the PeerID from whom this message comes from.

Parameters:
a_fromPeerIDThe PeerID from whom this message comes from
void Tonido::Data::Message::setFromService ( const std::string &  a_fromService)

Set the caller service of this message.

Parameters:
a_fromServicethe name of the service who sent this message
void Tonido::Message::setRawData ( const char *  i_Buffer,
uint64_bt  i_BufferLength 
)

Sets the payload that is part of this message.

The user supplied buffer will be copied to a new buffer and will be deleted when this message is destroyed.

void Tonido::Data::Message::setRawData ( const Data::RawData::SharedPtr &  a_rawData)

Sets the payload that is part of this message.

The data is copied into the Message

void Tonido::Data::Message::setToPeerID ( const Tonido::Data::PeerID a_toPeerID)

Sets to whom the message is being sent to.

Parameters:
a_toPeerIDID of the peer to whom the message is being sent to

Generated on Wed Oct 12 2011 21:46:53. © CodeLathe LLC 2007-2011. All Rights Reserved.