cluster::Packet Class Reference

Cluster packet base type. More...

#include <cluster/Packets/Packet.h>

Inheritance diagram for cluster::Packet:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Packet ()
 Create a new empty packet.
 Packet (std::vector< vpr::Uint8 > *data)
 Copy the given data, and parse the header.
virtual ~Packet ()
 Free all memory used by internal data.
void dump ()
 Dump all internal data to the screen.
vpr::Uint16 getPacketType ()
 Get the type of this packet.
virtual void printData (int debug_level)=0
 Print the internal data in a readable format.
vpr::ObjectReader * getPacketReader ()
 Return the vpr::PacketReader object used to retrieve data from the packet.
vpr::GUID getPluginId ()
 Get the GUID of the Plugin that should handle this packet.
HeadergetHeader ()
 Get the header for this packet.
std::vector< vpr::Uint8 > * getData ()
 Get a std::vector containing all internal data.
void setHeader (Header *head)
virtual void parse (vpr::BufferObjectReader *reader)=0

Protected Attributes

HeadermHeader
 Header used to specify the type/size of this packet.
vpr::BufferObjectReader * mPacketReader
 ObjectReader that is used to parse all data.
vpr::BufferObjectWriter * mPacketWriter
 ObjectWriter that is used to serialize all data.
std::vector< vpr::Uint8 > mData
 std::vector which contains all internal data
vpr::GUID mPluginId
 GUID that specifies which plugin is responcsible for this packet.

Detailed Description

Cluster packet base type.

Definition at line 60 of file Packet.h.


Constructor & Destructor Documentation

cluster::Packet::Packet (  ) 

Create a new empty packet.

Definition at line 45 of file Packet.cpp.

References mData, mPacketReader, and mPacketWriter.

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

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

Copy the given data, and parse the header.

Definition at line 51 of file Packet.cpp.

References mData, mPacketReader, and mPacketWriter.

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

cluster::Packet::~Packet (  )  [virtual]

Free all memory used by internal data.

Definition at line 61 of file Packet.cpp.

References mHeader, mPacketReader, and mPacketWriter.

00062    {
00063       delete mHeader;
00064       delete mPacketReader;
00065      delete mPacketWriter;
00066      //delete mData;
00067    }


Member Function Documentation

void cluster::Packet::dump (  ) 

Dump all internal data to the screen.

Definition at line 69 of file Packet.cpp.

References cluster::Header::dump(), mData, and mHeader.

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

vpr::Uint16 cluster::Packet::getPacketType (  ) 

Get the type of this packet.

Definition at line 88 of file Packet.cpp.

References cluster::Header::getPacketType(), and mHeader.

Referenced by cluster::StartBarrierPlugin::handlePacket(), gadget::RemoteInputManager::handlePacket(), cluster::ApplicationDataManager::handlePacket(), gadget::AbstractNetworkManager::handlePacket(), and gadget::Node::send().

00089    {
00090       return mHeader->getPacketType();
00091    }

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

Print the internal data in a readable format.

Implemented in cluster::ApplicationDataAck, cluster::ApplicationDataRequest, cluster::ConnectionAck, cluster::ConnectionRequest, cluster::DataPacket, cluster::DeviceAck, cluster::DeviceRequest, cluster::EndBlock, cluster::StartBlock, cluster::SyncAck, and cluster::SyncRequest.

Definition at line 93 of file Packet.cpp.

References gadgetDBG_RIM(), mHeader, and cluster::Header::printData().

Referenced by cluster::SyncRequest::printData(), cluster::SyncAck::printData(), cluster::StartBlock::printData(), cluster::DeviceRequest::printData(), cluster::DeviceAck::printData(), cluster::ConnectionRequest::printData(), cluster::ConnectionAck::printData(), cluster::ApplicationDataRequest::printData(), cluster::ApplicationDataAck::printData(), and gadget::Node::update().

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

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

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

Definition at line 96 of file Packet.h.

00097    {
00098       return mPacketReader;
00099    }

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

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

Definition at line 104 of file Packet.h.

Referenced by gadget::AbstractNetworkManager::handlePacket().

00105    {
00106       return mPluginId;
00107    }

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

Get the header for this packet.

Definition at line 112 of file Packet.h.

Referenced by gadget::Node::send(), cluster::ApplicationDataServer::serializeAndSend(), and gadget::DeviceServer::updateLocalData().

00113    {
00114       return mHeader;
00115    }

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

Get a std::vector containing all internal data.

Definition at line 120 of file Packet.h.

Referenced by gadget::Node::send().

00121    {
00122       return &mData;
00123    }

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

Definition at line 125 of file Packet.h.

Referenced by gadget::Node::recvPacket().

00126    {
00127       mHeader = head;
00128    }

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

Implemented in cluster::ApplicationDataAck, cluster::ApplicationDataRequest, cluster::ConnectionAck, cluster::ConnectionRequest, cluster::DataPacket, cluster::DeviceAck, cluster::DeviceRequest, cluster::EndBlock, cluster::StartBlock, cluster::SyncAck, and cluster::SyncRequest.

Referenced by gadget::Node::recvPacket().


Member Data Documentation

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

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

Definition at line 132 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 133 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 134 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 135 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 136 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 Thu Jan 4 10:44:24 2007 for Gadgeteer by  doxygen 1.5.1