#include <DataPacket.h>
Inheritance diagram for cluster::DataPacket:


Public Methods | |
| DataPacket () | |
| Default constructor used by the PacketFactory. More... | |
| DataPacket (const vpr::GUID &plugin_id, const vpr::GUID &object_id, std::vector< vpr::Uint8 > *data) | |
| Create a DataPacket to send raw data accross the network. More... | |
| virtual | ~DataPacket () |
| Clean up all unused memory. More... | |
| void | serialize () |
| Serializes member variables into a data stream. More... | |
| virtual void | parse (vpr::BufferObjectReader *reader) |
| Parses the data stream into the local member variables. More... | |
| virtual void | printData (int debug_level) |
| Print the data to the screen in a readable form. More... | |
| vpr::GUID | getObjectId () |
| Return the GUID of the object that we are sending raw data for. More... | |
| std::vector< vpr::Uint8 > * | getDeviceData () |
| Return a pointer to the raw data that we are sending across the network. More... | |
Static Public Methods | |
| vpr::Uint16 | getPacketFactoryType () |
| Return the type of this packet. More... | |
|
|
Default constructor used by the PacketFactory.
Definition at line 53 of file DataPacket.cpp.
00053 : mDeviceData(NULL)
00054 {;}
|
|
||||||||||||||||
|
Create a DataPacket to send raw data accross the network.
Definition at line 56 of file DataPacket.cpp. References cluster::Packet::mHeader, cluster::Packet::mPluginId, and serialize.
00057 : mObjectId(object_id), mDeviceData(data)
00058 {
00059 mPluginId = plugin_id;
00060
00061 // Create a Header for this packet with the correect type and size.
00062 mHeader = new Header(Header::RIM_PACKET,
00063 Header::RIM_DATA_PACKET,
00064 Header::RIM_PACKET_HEAD_SIZE
00065 + 16 /*Plugin GUID*/
00066 + 16 /*Plugin GUID*/
00067 + mDeviceData->size(),
00068 0/*Field not curently used*/);
00069 // Serialize the given data.
00070 serialize();
00071 }
|
|
|
Clean up all unused memory.
Definition at line 66 of file DataPacket.h.
00067 {
00068 delete mDeviceData;
00069 }
|
|
|
Serializes member variables into a data stream.
Definition at line 73 of file DataPacket.cpp. References cluster::Packet::mHeader, cluster::Packet::mPacketWriter, and cluster::Packet::mPluginId. Referenced by DataPacket.
00074 {
00075 // Clear the data stream.
00076 mPacketWriter->getData()->clear();
00077 mPacketWriter->setCurPos(0);
00078
00079 // Serialize the header.
00080 mHeader->serializeHeader();
00081
00082 // Serialize plugin GUID.
00083 mPluginId.writeObject(mPacketWriter);
00084
00085 // Serialize device GUID.
00086 mObjectId.writeObject(mPacketWriter);
00087
00088 // mDeviceData is a pointer that points at the DeviceData located in the DeviceServer
00089 // this data will be updated every frame before sent.
00090 }
|
|
|
Parses the data stream into the local member variables.
Implements cluster::Packet. Definition at line 92 of file DataPacket.cpp. References cluster::Packet::mHeader, and cluster::Packet::mPluginId.
00093 {
00094 // De-Serialize plugin GUID
00095 mPluginId.readObject(reader);
00096
00097 // De-Serialize plugin GUID
00098 mObjectId.readObject(reader);
00099
00100 mDeviceData = new std::vector<vpr::Uint8>();
00101
00102 unsigned int data_size = mHeader->getPacketLength() - Header::RIM_PACKET_HEAD_SIZE - 32;
00103 for(unsigned int i = 0 ; i < data_size ; i++)
00104 {
00105 mDeviceData->push_back(*(reader->readRaw(1)));
00106 }
00107 }
|
|
|
Print the data to the screen in a readable form.
Implements cluster::Packet. Definition at line 109 of file DataPacket.cpp.
00110 {
00111 // NOTE: This should be removed if any of the below code ever puts
00112 // debug_level to use.
00113
00114 boost::ignore_unused_variable_warning(debug_level);
00115
00116 /*
00117 vprDEBUG_BEGIN(gadgetDBG_RIM,debug_level)
00118 << clrOutBOLD(clrYELLOW,"==== Device Data Packet ====\n") << vprDEBUG_FLUSH;
00119
00120 Packet::printData(debug_level);
00121
00122 vprDEBUG(gadgetDBG_RIM,debug_level)
00123 << clrOutBOLD(clrYELLOW, "Plugin ID: ") << mPluginId.toString()
00124 << std::endl << vprDEBUG_FLUSH;
00125 vprDEBUG(gadgetDBG_RIM,debug_level)
00126 << clrOutBOLD(clrYELLOW, "Object ID: ") << mObjectId.toString()
00127 << std::endl << vprDEBUG_FLUSH;
00128
00129 vprDEBUG_END(gadgetDBG_RIM,debug_level)
00130 << clrOutBOLD(clrYELLOW,"============================\n") << vprDEBUG_FLUSH;
00131 */
00132 }
|
|
|
Return the type of this packet.
Definition at line 89 of file DataPacket.h.
00090 {
00091 return(Header::RIM_DATA_PACKET);
00092 }
|
|
|
Return the GUID of the object that we are sending raw data for.
Definition at line 97 of file DataPacket.h.
00098 { return mObjectId; }
|
|
|
Return a pointer to the raw data that we are sending across the network.
Definition at line 103 of file DataPacket.h.
00104 { return mDeviceData; }
|
1.2.14 written by Dimitri van Heesch,
© 1997-2002