TCPmessage Class Reference

This class defines a modular message to be passed over TCP connections. More...

#include <Beowulf/TCPmessage.H>

Collaboration diagram for TCPmessage:
Collaboration graph
[legend]

List of all members.

Classes

struct  TCPmessageHeader
 This private struct is the common header in all TCPmessage objects.

Public Member Functions

 TCPmessage ()
 uninitialized constructor (for pointers)
 TCPmessage (const int32 msgid, const int32 msgaction, const float msgeti=0.0F)
 constructor with empty message body
 TCPmessage (const int32 msgid, const int32 msgaction, const float msgeti, const void *buf, const int bufsize)
 constructor with copy of given message body
 TCPmessage (const TCPmessage &m)
 copy constructor
TCPmessageoperator= (const TCPmessage &m)
 assignment
 ~TCPmessage ()
 destructor
void addImage (const Image< PixRGB< byte > > &im)
 method to add elements into a message to be sent out
void addImage (const Image< byte > &im)
 method to add elements into a message to be sent out
void addImage (const Image< float > &im)
 method to add elements into a message to be sent out
void addImageSet (const ImageSet< float > &im)
 method to add elements into a message to be sent out
void addFixation (const Fixation &fix)
 method to add elements into a message to be sent out
void addString (const char *str)
 method to add elements into a message to be sent out
void addInt32 (const int32 val)
 method to add elements into a message to be sent out
void addFloat (const float val)
 method to add elements into a message to be sent out
void addDouble (const double val)
 method to add elements into a message to be sent out
void addInt64 (const int64 val)
 method to add elements into a message to be sent out
void setID (const int32 id)
 modify message ID
int32 getID () const
 get message ID
void setAction (const int32 ac)
 modify message action
int32 getAction () const
 get message action
void setETI (const float eti)
 modify message eti (estimated time to idle)
float getETI () const
 get message eti (estimated time to idle)
int32 getSize () const
 get total message size (mostly for debuging purposes)
bool isBusy () const
 check whether message is busy (sending or receiving data):
void reset (const int32 msgid, const int32 msgaction, const float msgeti=0.0F)
 empty old contents and get ready for a re-use:
void freeMem ()
 free memory:
void getElementRaw (void **elem, int32 &typ)
 DONT'T USE THIS; use one of the type-specific getElement functions below.
Image< PixRGB< byte > > getElementColByteIma ()
 Get a color byte image from the message stream.
Image< bytegetElementByteIma ()
 Get a byte image from the message stream.
Image< float > getElementFloatIma ()
 Get a float image from the message stream.
ImageSet< float > getElementFloatImaSet ()
 Get a float image set from the message stream.
int32 getElementInt32 ()
 Get an int32 value from the message stream.
int64 getElementInt64 ()
 Get an int64 value from the message stream.
double getElementDouble ()
 Get a double value from the message stream.
float getElementFloat ()
 Get a float value from the message stream.
Fixation getElementFixation ()
 Get a Fixation from the message stream.
std::string getElementString ()
 Get a string value from the message stream.
template<class T >
void unpack (const T *data, const int nitem)
 unpack some data from message (memory must be pre-allocated):

Friends

class TCPcliServ
 make our private methods accessible to TCPcliServ:

Detailed Description

This class defines a modular message to be passed over TCP connections.

The basic message structure is as follows:

Definition at line 92 of file TCPmessage.H.


Constructor & Destructor Documentation

TCPmessage::TCPmessage (  ) 

uninitialized constructor (for pointers)

Definition at line 56 of file TCPmessage.C.

References reset().

TCPmessage::TCPmessage ( const int32  msgid,
const int32  msgaction,
const float  msgeti = 0.0F 
)

constructor with empty message body

Parameters:
msgid a message identification (user-defined)
msgaction additional field where users can specify an action to be executed when this message is received
msgeti estimated time to idle, in seconds. This is used for automatic load balancing, where the Beowulf class will dispatch processing to nodes with shorter eti's in priority, when a load-balanced send is requested. If you are not doing load balancing, just use the default of 0.0.

Definition at line 61 of file TCPmessage.C.

References reset().

TCPmessage::TCPmessage ( const int32  msgid,
const int32  msgaction,
const float  msgeti,
const void *  buf,
const int  bufsize 
)

constructor with copy of given message body

NOTE: we do a deep copy of the given buffer, so that it can be freed immediately upon return from this constructor

Definition at line 67 of file TCPmessage.C.

References reset().

TCPmessage::TCPmessage ( const TCPmessage m  ) 

copy constructor

Definition at line 79 of file TCPmessage.C.

TCPmessage::~TCPmessage (  ) 

destructor

Definition at line 92 of file TCPmessage.C.


Member Function Documentation

void TCPmessage::addDouble ( const double  val  ) 

method to add elements into a message to be sent out

Definition at line 162 of file TCPmessage.C.

Referenced by SingleChannelBeoServer::check(), SingleChannelBeo::handleInput(), and setupVentralPacket().

void TCPmessage::addFixation ( const Fixation fix  ) 

method to add elements into a message to be sent out

Definition at line 131 of file TCPmessage.C.

void TCPmessage::addFloat ( const float  val  ) 

method to add elements into a message to be sent out

Definition at line 156 of file TCPmessage.C.

Referenced by TestJoyStickListener::axis(), main(), and setupVentralPacket().

void TCPmessage::addImage ( const Image< float > &  im  ) 

method to add elements into a message to be sent out

Definition at line 114 of file TCPmessage.C.

References Image< T >::getArrayPtr(), Image< T >::getHeight(), Image< T >::getSize(), and Image< T >::getWidth().

void TCPmessage::addImage ( const Image< byte > &  im  ) 

method to add elements into a message to be sent out

Definition at line 105 of file TCPmessage.C.

References Image< T >::getArrayPtr(), Image< T >::getHeight(), Image< T >::getSize(), and Image< T >::getWidth().

void TCPmessage::addImage ( const Image< PixRGB< byte > > &  im  ) 

method to add elements into a message to be sent out

Definition at line 96 of file TCPmessage.C.

Referenced by addImageSet(), SingleChannelBeoServer::check(), computeCMAP(), SingleChannelBeo::handleInput(), main(), BeobotVisualCortex::masterProcess(), and setupVentralPacket().

void TCPmessage::addImageSet ( const ImageSet< float > &  im  ) 

method to add elements into a message to be sent out

Definition at line 123 of file TCPmessage.C.

References addImage(), and ImageSet< T >::size().

Referenced by SingleChannelBeoServer::check(), and setupDorsalPacket().

void TCPmessage::addInt32 ( const int32  val  ) 

method to add elements into a message to be sent out

Definition at line 144 of file TCPmessage.C.

Referenced by TestJoyStickListener::axis(), main(), setupDorsalPacket(), setupTrackingResultPacket(), and setupVentralPacket().

void TCPmessage::addInt64 ( const int64  val  ) 

method to add elements into a message to be sent out

Definition at line 150 of file TCPmessage.C.

void TCPmessage::addString ( const char *  str  ) 

method to add elements into a message to be sent out

Definition at line 138 of file TCPmessage.C.

Referenced by SingleChannelBeo::handleInput(), and main().

void TCPmessage::freeMem (  ) 

free memory:

Definition at line 177 of file TCPmessage.C.

References ArrayHandle< T >::swap().

Referenced by reset().

int32 TCPmessage::getAction (  )  const [inline]

get message action

Definition at line 344 of file TCPmessage.H.

Referenced by TCPcliServ::check(), Beowulf::receive(), and Beowulf::send().

Image< byte > TCPmessage::getElementByteIma (  ) 

Get a byte image from the message stream.

The current message element must have type TCPMSG_BYTEIMA

Definition at line 271 of file TCPmessage.C.

Referenced by SingleChannelBeoServer::check(), computeCMAP(), computeCMAP2(), and BeobotVisualCortex::slaveProcess().

Image< PixRGB< byte > > TCPmessage::getElementColByteIma (  ) 

Get a color byte image from the message stream.

The current message element must have type TCPMSG_COLBYTEIMA

Definition at line 264 of file TCPmessage.C.

Referenced by getSearchCommand(), and main().

double TCPmessage::getElementDouble (  ) 

Get a double value from the message stream.

The current message element must have type TCPMSG_DOUBLE

Definition at line 306 of file TCPmessage.C.

References unpack().

Referenced by SingleChannelBeoServer::check(), getSearchCommand(), main(), and SingleChannelBeo::waitForOutput().

Fixation TCPmessage::getElementFixation (  ) 

Get a Fixation from the message stream.

The current message element must have type TCPMSG_FIXATION

Definition at line 320 of file TCPmessage.C.

float TCPmessage::getElementFloat (  ) 

Get a float value from the message stream.

The current message element must have type TCPMSG_FLOAT

Definition at line 313 of file TCPmessage.C.

References unpack().

Referenced by getSearchCommand(), and main().

Image< float > TCPmessage::getElementFloatIma (  ) 

Get a float image from the message stream.

The current message element must have type TCPMSG_FLOATIMA

Definition at line 278 of file TCPmessage.C.

Referenced by SingleChannelBeoServer::check(), BeobotVisualCortex::masterCollect(), receiveCMAPS(), and SingleChannelBeo::waitForOutput().

ImageSet< float > TCPmessage::getElementFloatImaSet (  ) 

Get a float image set from the message stream.

The current message element must have type TCPMSG_FLOATIMASET

Definition at line 285 of file TCPmessage.C.

Referenced by getTrackCommand(), and SingleChannelBeo::waitForOutput().

int32 TCPmessage::getElementInt32 (  ) 

Get an int32 value from the message stream.

The current message element must have type TCPMSG_INT32

Definition at line 292 of file TCPmessage.C.

References unpack().

Referenced by getSearchCommand(), getTrackCommand(), main(), processDorsalResult(), and processVentralResult().

int64 TCPmessage::getElementInt64 (  ) 

Get an int64 value from the message stream.

The current message element must have type TCPMSG_INT64

Definition at line 299 of file TCPmessage.C.

References unpack().

void TCPmessage::getElementRaw ( void **  elem,
int32 typ 
)

DONT'T USE THIS; use one of the type-specific getElement functions below.

OK, only use this function if you need to handle multiple possible message types; if you know for sure which type of element you expect, then it is safer and more efficient to call one of the type-specific functions like getElementByteIma() or getElementInt32(); see below.

If you do need to use this raw function, then after calling it, typ will contain TCPMSG_xxx so that the type of elem can be inferred. CAUTION: object will be allocated with new; you must delete it when done with it!

Definition at line 188 of file TCPmessage.C.

References unpack().

std::string TCPmessage::getElementString (  ) 

Get a string value from the message stream.

The current message element must have type TCPMSG_STRING

Definition at line 327 of file TCPmessage.C.

References ASSERT, and unpack().

Referenced by SingleChannelBeoServer::check(), and main().

float TCPmessage::getETI (  )  const [inline]

get message eti (estimated time to idle)

Definition at line 352 of file TCPmessage.H.

Referenced by Beowulf::receive().

int32 TCPmessage::getID (  )  const [inline]

get message ID

Definition at line 336 of file TCPmessage.H.

Referenced by TCPcliServ::check(), computeCMAP(), computeCMAP2(), Beowulf::receive(), and Beowulf::send().

int32 TCPmessage::getSize (  )  const [inline]

get total message size (mostly for debuging purposes)

Definition at line 356 of file TCPmessage.H.

Referenced by TCPcliServ::check(), main(), and processVentralResult().

bool TCPmessage::isBusy (  )  const [inline]

check whether message is busy (sending or receiving data):

Definition at line 360 of file TCPmessage.H.

TCPmessage & TCPmessage::operator= ( const TCPmessage m  ) 

assignment

Definition at line 84 of file TCPmessage.C.

References ArrayHandle< T >::swap().

void TCPmessage::reset ( const int32  msgid,
const int32  msgaction,
const float  msgeti = 0.0F 
)
void TCPmessage::setAction ( const int32  ac  )  [inline]

modify message action

Definition at line 340 of file TCPmessage.H.

Referenced by BeobotVisualCortex::masterProcess().

void TCPmessage::setETI ( const float  eti  )  [inline]

modify message eti (estimated time to idle)

Definition at line 348 of file TCPmessage.H.

Referenced by computeCMAP().

void TCPmessage::setID ( const int32  id  )  [inline]

modify message ID

Definition at line 332 of file TCPmessage.H.

template<class T >
void TCPmessage::unpack ( const T *  data,
const int  nitem 
) [inline]

unpack some data from message (memory must be pre-allocated):

Definition at line 398 of file TCPmessage.H.

Referenced by getElementDouble(), getElementFloat(), getElementInt32(), getElementInt64(), getElementRaw(), and getElementString().


Friends And Related Function Documentation

friend class TCPcliServ [friend]

make our private methods accessible to TCPcliServ:

Definition at line 291 of file TCPmessage.H.


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:26:12 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3