GlobalObjects
Loading...
Searching...
No Matches
tcp::Message Class Reference

Contains a data stream which can be sent and received by the Tcp classes. More...

#include <TcpMessage.h>

Inheritance diagram for tcp::Message:

Public Member Functions

 Message (char *pszRawMsg, std::size_t nRawMsgSize, unsigned int uiMessageID, int iActionCode, const std::string &rstrInfo)
 
 Message (char *pszTransmitData, std::size_t nTransmitDataSize)
 
virtual ~Message ()
 
int getActionCode () const
 
std::string getInfo () const
 
unsigned int getMsgID () const
 
std::size_t getRawMsg (char *&prszRawMsg, bool bCopy=true)
 
char * getRawMsgPt ()
 
std::size_t getRawMsgSize () const
 
std::size_t getTransmitData (char *&prszSendMsg, bool bCopy=true)
 
char * getTransmitDataPt ()
 
std::size_t getTransmitDataSize () const
 
- Public Member Functions inherited from tcp::AbstractMessage
virtual ~AbstractMessage ()
 

Protected Member Functions

 Message ()
 
- Protected Member Functions inherited from tcp::AbstractMessage
 AbstractMessage ()
 

Private Member Functions

 Message (const Message &)
 
int initDataFromSendMsg ()
 
int initSendMsgFromData ()
 
Messageoperator= (const Message &)
 

Private Attributes

int m_iActionCode
 
std::size_t m_nRawMessageSize
 
std::size_t m_nTransmitDataSize
 
char * m_pszRawMessage
 
char * m_pszTransmitData
 
std::string m_strInfo
 
unsigned int m_uiMessageID
 

Detailed Description

Contains a data stream which can be sent and received by the Tcp classes.

The message data is preceded by a header consisting of

  • an abbreviation "hja-tcp" (0-terminated); a simple, non-secure way to filter foreign messages.
  • the size of the entire message, i.e. header plus message data (10 digits, 0-terminated), see m_nTransmitDataSize
  • a message ID (0-terminated), see m_uiMessageID
  • a ActionCode (0-terminated), see m_iActionCode
  • an info (0-terminated), see m_strInfo
Author
Helmut Jakoby

Constructor & Destructor Documentation

◆ Message() [1/4]

tcp::Message::Message ( )
protected

This constructor is not available.

◆ Message() [2/4]

tcp::Message::Message ( char * pszTransmitData,
std::size_t nTransmitDataSize )

A constructor that expects a data buffer and its size.

Parameters
[in]pszTransmitDataThe data buffer to be transmitted including all required Information:
  • the abbreviation "hja-tcp" (0-terminated) a simple non-secure way to filter foreign messages.
  • the size of the entire message, i.e. header plus message data (0-terminated)
  • A message ID (0-terminated)
  • a ActionCode (0-terminated)
  • an info (0-terminated)
  • the message data of the message
[in]nTransmitDataSizeThe size or length of the data buffer to be sent.
Attention
This object takes over the removal of the pszTransmitData from the memory.
Exceptions
eut::ErrorNExceptionAn exception is thrown if the attributes cannot be set from the data (e.g. because the header is incorrect).

◆ Message() [3/4]

tcp::Message::Message ( char * pszRawMsg,
std::size_t nRawMsgSize,
unsigned int uiMessageID,
int iActionCode,
const std::string & rstrInfo )

A constructor that can build a message to be sent from the transferred data.

Parameters
[in]pszRawMsgThe message data.
[in]nRawMsgSizeThe size or length of the message data.
[in]uiMessageIDA unique ID.
[in]iActionCodeThe ActionCode, see m_iActionCode.
[in]rstrInfoAn additional text info
Attention
This object removes the pszRawMsg from the memory
Exceptions
eut::ErrorNExceptionIf m_pszTransmitData cannot be set from the data (e.g. because attributes are invalid), an exception is thrown.

◆ ~Message()

virtual tcp::Message::~Message ( )
virtual

Destructor.

◆ Message() [4/4]

tcp::Message::Message ( const Message & )
private

The copy constructor is not available.

Member Function Documentation

◆ getActionCode()

int tcp::Message::getActionCode ( ) const

Returns the action code.

See also
ActionCode and ERRORS

◆ getInfo()

std::string tcp::Message::getInfo ( ) const

Liefert den Informationstext.

◆ getMsgID()

unsigned int tcp::Message::getMsgID ( ) const

Returns the unique ID.

◆ getRawMsg()

std::size_t tcp::Message::getRawMsg ( char *& prszRawMsg,
bool bCopy = true )

Returns the message data.

Parameters
[in,out]prszRawMsgHere the message data is delivered.
[in]bCopyIf set to true, memory is requested by this method for passed prszRawMsg, which must be released by the calling instance.
Returns
The return value indicates the data size.
Exceptions
eut::ErrorNExceptionAn exception is thrown if no memory could be requested.

◆ getRawMsgPt()

char * tcp::Message::getRawMsgPt ( )

Returns the message data.

◆ getRawMsgSize()

std::size_t tcp::Message::getRawMsgSize ( ) const

Returns the size of the message data.

◆ getTransmitData()

std::size_t tcp::Message::getTransmitData ( char *& prszSendMsg,
bool bCopy = true )

Returns the transmission data.

Parameters
[in,out]prszSendMsgHere the send data is delivered.
[in]bCopyIf set to true, memory is requested by this method for passed prszSendMsg, which must be released by the calling instance.
Returns
The return value indicates the data size.
Exceptions
eut::ErrorNExceptionAn exception is thrown if no memory could be requested.

◆ getTransmitDataPt()

char * tcp::Message::getTransmitDataPt ( )

Returns the transmission data.

◆ getTransmitDataSize()

std::size_t tcp::Message::getTransmitDataSize ( ) const

Returns the size of the send data.

◆ initDataFromSendMsg()

int tcp::Message::initDataFromSendMsg ( )
private

Sets its attributes from m_pszTransmitData. Is used by Message::Message( char *, std::size_t ).

Returns
A return value < 0 indicates an error.

◆ initSendMsgFromData()

int tcp::Message::initSendMsgFromData ( )
private

Builds m_pszTransmitData from its attributes. Is used by Message( char *, std::size_t, unsigned int, int, const std::string & ).

Returns
A return value < 0 indicates an error.

◆ operator=()

Message & tcp::Message::operator= ( const Message & )
private

The assignment operator is not available.

Member Data Documentation

◆ m_iActionCode

int tcp::Message::m_iActionCode
private

A code to signal a certain request if necessary.

See also
ActionCode
Attention
All numbers < 0 are reserved for error messages!
See also
ERRORS

◆ m_nRawMessageSize

std::size_t tcp::Message::m_nRawMessageSize
private

The size or length of the message data.

◆ m_nTransmitDataSize

std::size_t tcp::Message::m_nTransmitDataSize
private

The size or length of the send data (header plus message data).

◆ m_pszRawMessage

char* tcp::Message::m_pszRawMessage
private

The message data.

◆ m_pszTransmitData

char* tcp::Message::m_pszTransmitData
private

The complete send data of the message including header.

◆ m_strInfo

std::string tcp::Message::m_strInfo
private

A freely usable info.

◆ m_uiMessageID

unsigned int tcp::Message::m_uiMessageID
private

A unique ID.


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