FuseNetworkMessage Class Reference
[FireVision FUSE Network ProtocolFireVision Image Processing Framework and Applications]

FUSE Network Message. More...

#include <fvutils/net/fuse_message.h>

Inheritance diagram for FuseNetworkMessage:

List of all members.


Public Member Functions

 FuseNetworkMessage ()
 Constructor.
 FuseNetworkMessage (FUSE_message_t *msg)
 Constructor.
 FuseNetworkMessage (FUSE_message_type_t type, void *payload, size_t payload_size, bool copy_payload=false)
 Constructor.
 FuseNetworkMessage (FUSE_message_type_t type, FuseMessageContent *content)
 Content constructor.
 FuseNetworkMessage (FUSE_message_type_t type)
 Constructor without payload.
 ~FuseNetworkMessage ()
 Destructor.
uint32_t type () const
 Get message type.
size_t payload_size () const
 Get payload size.
void * payload () const
 Get pointer to payload.
const FUSE_message_tfmsg () const
 Get plain message.
template<typename MT >
MT * msg () const
 Get correctly casted payload.
template<typename MT >
MT * msg_copy () const
 Get copy of correctly casted payload.
template<typename MT >
MT * msgc () const
 Get correctly parsed output.
void pack ()
 Pack data for sending.
void set_payload (void *payload, size_t payload_size)
 Set payload.
void set (FUSE_message_t &msg)
 Set from message.

Protected Attributes

FUSE_message_t _msg
 Internal message.

Detailed Description

FUSE Network Message.

This is the basic entity for messages that are sent over the network. Either just use this message to send arbitrary payload or derive this class for more complex behavior or nice encapsulations of messages.

Author:
Tim Niemueller

Definition at line 36 of file fuse_message.h.


Constructor & Destructor Documentation

FuseNetworkMessage::FuseNetworkMessage (  ) 

Constructor.

Definition at line 45 of file fuse_message.cpp.

References _msg.

FuseNetworkMessage::FuseNetworkMessage ( FUSE_message_t msg  ) 

Constructor.

Parameters:
msg message information to copy

Definition at line 55 of file fuse_message.cpp.

References _msg.

FuseNetworkMessage::FuseNetworkMessage ( FUSE_message_type_t  type,
void *  payload,
size_t  payload_size,
bool  copy_payload = false 
)

Constructor.

Parameters:
type message type
payload payload
payload_size size of payload
copy_payload if true payload is copied, otherwise payload is referenced and ownership of payload is claimed.

Definition at line 69 of file fuse_message.cpp.

References _msg, FUSE_message_t::header, FUSE_header_t::message_type, FUSE_message_t::payload, and FUSE_header_t::payload_size.

FuseNetworkMessage::FuseNetworkMessage ( FUSE_message_type_t  type,
FuseMessageContent content 
)

Content constructor.

Construct a message with complex message content.

Parameters:
type FUSE message type
content complex message content.

Definition at line 104 of file fuse_message.cpp.

References _msg, FUSE_message_t::header, FUSE_header_t::message_type, FUSE_message_t::payload, and FUSE_header_t::payload_size.

FuseNetworkMessage::FuseNetworkMessage ( FUSE_message_type_t  type  ) 

Constructor without payload.

Constructs message without payload.

Parameters:
type FUSE message type

Definition at line 90 of file fuse_message.cpp.

References _msg, FUSE_message_t::header, FUSE_header_t::message_type, FUSE_message_t::payload, and FUSE_header_t::payload_size.

FuseNetworkMessage::~FuseNetworkMessage (  ) 

Destructor.

Definition at line 113 of file fuse_message.cpp.

References _msg, FuseMessageContent::free_payload(), and FUSE_message_t::payload.


Member Function Documentation

const FUSE_message_t & FuseNetworkMessage::fmsg (  )  const

Get plain message.

Returns:
plain message

Definition at line 160 of file fuse_message.cpp.

References _msg.

Referenced by FuseNetworkTransceiver::send().

template<typename MT >
MT* FuseNetworkMessage::msg (  )  const [inline]

Get correctly casted payload.

Use this method to cast the payload to a specific type. The size is check as a sanity check and a TypeMismatchException is thrown if the size does not match.

Returns:
casted message
Exceptions:
TypeMismatchException payload size does not match requested type

Definition at line 62 of file fuse_message.h.

References _msg, FUSE_message_t::payload, and payload_size().

Referenced by FuseClient::loop(), FuseServerClientThread::process_getimage_message(), FuseServerClientThread::process_getimageinfo_message(), FuseServerClientThread::process_getlut_message(), and FuseServerClientThread::process_greeting_message().

template<typename MT >
MT* FuseNetworkMessage::msg_copy (  )  const [inline]

Get copy of correctly casted payload.

Use this method to cast the payload to a specific type. The size is check as a sanity check and a TypeMismatchException is thrown if the size does not match.

Returns:
copy of casted message
Exceptions:
TypeMismatchException payload size does not match requested type

Definition at line 80 of file fuse_message.h.

References _msg, FUSE_message_t::payload, and payload_size().

template<typename MT >
MT* FuseNetworkMessage::msgc (  )  const [inline]

Get correctly parsed output.

Use this method to cast the payload to a specific complex type. You can use this routine to parse complex messages that are derived from FuseComplexMessageContent. Note that the class must provide a constructor that takes three parameters: The message type, a pointer to the payload and the payload size. From this the class shall parse the output and throw an exception if that for whatever reason fails.

Returns:
casted message
Exceptions:
TypeMismatchException payload size does not match requested type

Definition at line 102 of file fuse_message.h.

References _msg, FUSE_message_t::payload, and type().

Referenced by FuseServerClientThread::process_setlut_message().

void FuseNetworkMessage::pack (  ) 

Pack data for sending.

Use this if any additional packing is needed before sending the data (for example if using a DynamicBuffer).

Definition at line 197 of file fuse_message.cpp.

References _msg, FUSE_message_t::header, FuseMessageContent::payload(), FUSE_message_t::payload, FuseMessageContent::payload_size(), FUSE_header_t::payload_size, and FuseMessageContent::serialize().

Referenced by FuseNetworkTransceiver::send().

void * FuseNetworkMessage::payload (  )  const

void FuseNetworkMessage::set ( FUSE_message_t msg  ) 

Set from message.

Parameters:
msg reference to message. Content is deep-copied.

Definition at line 187 of file fuse_message.cpp.

References _msg.

void FuseNetworkMessage::set_payload ( void *  payload,
size_t  payload_size 
)

Set payload.

Payload is referenced and ownership claimed.

Parameters:
payload payload
payload_size size of payload

Definition at line 172 of file fuse_message.cpp.

References _msg, FUSE_message_t::header, FUSE_message_t::payload, and FUSE_header_t::payload_size.

uint32_t FuseNetworkMessage::type (  )  const

Get message type.

Returns:
message type

Definition at line 130 of file fuse_message.cpp.

References _msg, FUSE_message_t::header, and FUSE_header_t::message_type.

Referenced by FuseClient::loop(), and msgc().


Member Data Documentation

Internal message.

Fill in derivatives.

Definition at line 122 of file fuse_message.h.

Referenced by fmsg(), FuseNetworkMessage(), msg(), msg_copy(), msgc(), pack(), payload(), payload_size(), set(), set_payload(), type(), and ~FuseNetworkMessage().


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