Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

cluster::Packet Class Reference

#include <Packet.h>

Inheritance diagram for cluster::Packet:

Inheritance graph
[legend]
Collaboration diagram for cluster::Packet:

Collaboration graph
[legend]
List of all members.

Public Methods

 Packet ()
 Create a new empty packet. More...

 Packet (std::vector< vpr::Uint8 > *data)
 Copy the given data, and parse the header. More...

virtual ~Packet ()
 Free all memory used by internal data. More...

void recv (Header *packet_head, ClusterNode *node) throw (cluster::ClusterException)
 Construct a packet using the given packet header and socketstream. More...

void dump ()
 Dump all internal data to the screen. More...

vpr::Uint16 getPacketType ()
 Get the type of this packet. More...

virtual void printData (int debug_level)=0
 Print the internal data in a readable format. More...

vpr::ObjectReader * getPacketReader ()
 Return the vpr::PacketReader object used to retrieve data from the packet. More...

vpr::GUID getPluginId ()
 Get the GUID of the Plugin that should handle this packet. More...

HeadergetHeader ()
 Get the header for this packet. More...

std::vector< vpr::Uint8 > * getData ()
 Get a std::vector containing all internal data. More...

void setHeader (Header *head)
virtual void parse (vpr::BufferObjectReader *reader)=0

Protected Attributes

HeadermHeader
 Header used to specify the type/size of this packet. More...

vpr::BufferObjectReader * mPacketReader
 ObjectReader that is used to parse all data. More...

vpr::BufferObjectWriter * mPacketWriter
 ObjectWriter that is used to serialize all data. More...

std::vector< vpr::Uint8 > mData
 std::vector which contains all internal data. More...

vpr::GUID mPluginId
 GUID that specifies which plugin is responcsible for this packet. More...


Constructor & Destructor Documentation

cluster::Packet::Packet  
 

Create a new empty packet.

Definition at line 47 of file Packet.cpp.

References mData, mPacketReader, and mPacketWriter.

00047                   : mPluginId()
00048    {
00049       //mData = new std::vector<vpr::Uint8>(RIM_PACKET_HEAD_SIZE);
00050       mPacketReader = new vpr::BufferObjectReader(&mData);
00051       mPacketWriter= new vpr::BufferObjectWriter(&mData);
00052    }

cluster::Packet::Packet std::vector< vpr::Uint8 > *    data
 

Copy the given data, and parse the header.

Definition at line 53 of file Packet.cpp.

References mData, mPacketReader, and mPacketWriter.

00053                                            : mPluginId()
00054    {
00055       //We must Copy
00056       mData = *(data);
00057       mPacketReader = new vpr::BufferObjectReader(&mData);
00058       mPacketWriter= new vpr::BufferObjectWriter(&mData);
00059 
00060       //parseHeader();
00061    }

cluster::Packet::~Packet   [virtual]
 

Free all memory used by internal data.

Definition at line 63 of file Packet.cpp.

References mHeader, mPacketReader, and mPacketWriter.

00064    {
00065       delete mHeader;
00066       delete mPacketReader;
00067      delete mPacketWriter;
00068      //delete mData;
00069    }


Member Function Documentation

void cluster::Packet::recv Header   packet_head,
ClusterNode   node
throw (cluster::ClusterException)
 

Construct a packet using the given packet header and socketstream.

void cluster::Packet::dump  
 

Dump all internal data to the screen.

Definition at line 71 of file Packet.cpp.

References mData, and mHeader.

00072    {
00073       if (mHeader != NULL)
00074       {
00075          mHeader->dump();
00076       }
00077       else
00078       {
00079          std::cout << "Could not dump Header since it is NULL!" << std::endl;
00080       }
00081       std::cout << "Dumping Packet(" << mData.size() << " bytes): ";
00082       for ( std::vector<vpr::Uint8>::iterator i = mData.begin();
00083            i!= mData.end(); i++ )
00084       {
00085          std::cout << (int)*i << " ";
00086       }
00087       std::cout << std::endl;
00088    }

vpr::Uint16 cluster::Packet::getPacketType  
 

Get the type of this packet.

Definition at line 90 of file Packet.cpp.

References mHeader.

00091    {
00092       return mHeader->getPacketType();
00093    }

void cluster::Packet::printData int    debug_level [pure virtual]
 

Print the internal data in a readable format.

Implemented in cluster::ApplicationDataAck.

Definition at line 95 of file Packet.cpp.

References gadgetDBG_RIM, and mHeader.

00096    {
00097       if (mHeader != NULL)
00098       {
00099          mHeader->printData(debug_level);
00100          /*
00101          vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_LVL) 
00102             << clrOutBOLD(clrCYAN,"\n====== Packet Header ======")
00103             << "\nRIMCode:    " << mHeader->getRIMCode()
00104             << "\nPacketType: " << mHeader->getPacketType()
00105             << "\nFrame #:    " << mHeader->getFrame()
00106             << "\nLength:     " << mHeader->getPacketLength() << std::endl
00107             << vprDEBUG_FLUSH;               
00108          */            
00109       }
00110       else
00111       {
00112       vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_LVL) 
00113          << clrOutBOLD(clrRED,"[Packet::printData] Header is still NULL, can not print data!")
00114          << vprDEBUG_FLUSH;               
00115       }
00116    }

vpr::ObjectReader* cluster::Packet::getPacketReader   [inline]
 

Return the vpr::PacketReader object used to retrieve data from the packet.

Definition at line 93 of file Packet.h.

00094    {
00095       return mPacketReader;
00096    }

vpr::GUID cluster::Packet::getPluginId   [inline]
 

Get the GUID of the Plugin that should handle this packet.

Definition at line 101 of file Packet.h.

00101 { return mPluginId; }

Header* cluster::Packet::getHeader   [inline]
 

Get the header for this packet.

Definition at line 106 of file Packet.h.

00107    {
00108       return mHeader;
00109    }

std::vector<vpr::Uint8>* cluster::Packet::getData   [inline]
 

Get a std::vector containing all internal data.

Definition at line 114 of file Packet.h.

00115    {
00116       return &mData;
00117    }

void cluster::Packet::setHeader Header   head [inline]
 

Definition at line 119 of file Packet.h.

00120    {
00121       mHeader = head;
00122    }

virtual void cluster::Packet::parse vpr::BufferObjectReader *    reader [pure virtual]
 

Implemented in cluster::ApplicationDataAck.


Member Data Documentation

Header* cluster::Packet::mHeader [protected]
 

Header used to specify the type/size of this packet.

Definition at line 126 of file Packet.h.

Referenced by cluster::ApplicationDataAck::ApplicationDataAck, cluster::ApplicationDataRequest::ApplicationDataRequest, cluster::ConnectionAck::ConnectionAck, cluster::ConnectionRequest::ConnectionRequest, cluster::DataPacket::DataPacket, cluster::DeviceAck::DeviceAck, cluster::DeviceRequest::DeviceRequest, dump, cluster::EndBlock::EndBlock, getPacketType, cluster::DataPacket::parse, printData, cluster::SyncRequest::serialize, cluster::SyncAck::serialize, cluster::StartBlock::serialize, cluster::EndBlock::serialize, cluster::DeviceRequest::serialize, cluster::DeviceAck::serialize, cluster::DataPacket::serialize, cluster::ConnectionRequest::serialize, cluster::ConnectionAck::serialize, cluster::ApplicationDataRequest::serialize, cluster::ApplicationDataAck::serialize, cluster::StartBlock::StartBlock, cluster::SyncAck::SyncAck, cluster::SyncRequest::SyncRequest, and ~Packet.

vpr::BufferObjectReader* cluster::Packet::mPacketReader [protected]
 

ObjectReader that is used to parse all data.

Definition at line 127 of file Packet.h.

Referenced by Packet, and ~Packet.

vpr::BufferObjectWriter* cluster::Packet::mPacketWriter [protected]
 

ObjectWriter that is used to serialize all data.

Definition at line 128 of file Packet.h.

Referenced by Packet, cluster::SyncRequest::serialize, cluster::SyncAck::serialize, cluster::StartBlock::serialize, cluster::EndBlock::serialize, cluster::DeviceRequest::serialize, cluster::DeviceAck::serialize, cluster::DataPacket::serialize, cluster::ConnectionRequest::serialize, cluster::ConnectionAck::serialize, cluster::ApplicationDataRequest::serialize, cluster::ApplicationDataAck::serialize, and ~Packet.

std::vector<vpr::Uint8> cluster::Packet::mData [protected]
 

std::vector which contains all internal data.

Definition at line 129 of file Packet.h.

Referenced by dump, and Packet.

vpr::GUID cluster::Packet::mPluginId [protected]
 

GUID that specifies which plugin is responcsible for this packet.

Definition at line 130 of file Packet.h.

Referenced by cluster::ApplicationDataAck::ApplicationDataAck, cluster::ApplicationDataRequest::ApplicationDataRequest, cluster::DataPacket::DataPacket, cluster::DeviceAck::DeviceAck, cluster::DeviceRequest::DeviceRequest, cluster::StartBlock::parse, cluster::DeviceRequest::parse, cluster::DeviceAck::parse, cluster::DataPacket::parse, cluster::ApplicationDataRequest::parse, cluster::ApplicationDataAck::parse, cluster::StartBlock::printData, cluster::DeviceRequest::printData, cluster::DeviceAck::printData, cluster::ApplicationDataRequest::printData, cluster::ApplicationDataAck::printData, cluster::StartBlock::serialize, cluster::DeviceRequest::serialize, cluster::DeviceAck::serialize, cluster::DataPacket::serialize, cluster::ApplicationDataRequest::serialize, cluster::ApplicationDataAck::serialize, and cluster::StartBlock::StartBlock.


The documentation for this class was generated from the following files:
Generated on Sun May 2 14:26:46 2004 for Gadgeteer by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002