00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <boost/concept_check.hpp>
00034
00035 #include <gadget/Util/Debug.h>
00036
00037 #include <cluster/Packets/DeviceRequest.h>
00038 #include <cluster/Packets/PacketFactory.h>
00039
00040 namespace cluster
00041 {
00042 CLUSTER_REGISTER_CLUSTER_PACKET_CREATOR(DeviceRequest);
00043
00044 DeviceRequest::DeviceRequest(const vpr::GUID& plugin_guid, const std::string& device_name)
00045 {
00046
00047 mDeviceName = device_name;
00048 mPluginId = plugin_guid;
00049
00050
00051 mHeader = new Header(Header::RIM_PACKET,
00052 Header::RIM_DEVICE_REQ,
00053 Header::RIM_PACKET_HEAD_SIZE
00054 + 16
00055 + vpr::BufferObjectReader::STRING_LENGTH_SIZE
00056 + mDeviceName.size(),
00057 0);
00058
00059 serialize();
00060 }
00061
00062 void DeviceRequest::serialize()
00063 {
00064
00065 mPacketWriter->getData()->clear();
00066 mPacketWriter->setCurPos(0);
00067
00068
00069 mHeader->serializeHeader();
00070
00071
00072 mPluginId.writeObject(mPacketWriter);
00073
00074
00075 mPacketWriter->writeString(mDeviceName);
00076 }
00077 void DeviceRequest::parse(vpr::BufferObjectReader* reader)
00078 {
00079
00080 mPluginId.readObject(reader);
00081
00082
00083 mDeviceName = reader->readString();
00084 }
00085
00086 void DeviceRequest::printData(int debug_level)
00087 {
00088 vprDEBUG_BEGIN(gadgetDBG_RIM,debug_level)
00089 << clrOutBOLD(clrYELLOW,"==== Device Request Packet Data ====\n") << vprDEBUG_FLUSH;
00090
00091 Packet::printData(debug_level);
00092
00093 vprDEBUG(gadgetDBG_RIM,debug_level)
00094 << clrOutBOLD(clrYELLOW, "Plugin GUID: ") << mPluginId.toString()
00095 << std::endl << vprDEBUG_FLUSH;
00096 vprDEBUG(gadgetDBG_RIM,debug_level)
00097 << clrOutBOLD(clrYELLOW, "Device Name: ") << mDeviceName
00098 << std::endl << vprDEBUG_FLUSH;
00099
00100 vprDEBUG_END(gadgetDBG_RIM,debug_level)
00101 << clrOutBOLD(clrYELLOW,"====================================\n") << vprDEBUG_FLUSH;
00102 }
00103 }