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

cluster::DeviceAck Class Reference

#include <DeviceAck.h>

Inheritance diagram for cluster::DeviceAck:

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

Collaboration graph
[legend]
List of all members.

Public Methods

 DeviceAck ()
 DeviceAck (const vpr::GUID &plugin_id, const vpr::GUID &id, const std::string &device_name, const std::string &device_base_type, bool ack)
 Create a DeviceAck packet to acknowledge a ApplicationDataRequest. 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 getId ()
 Return the GUID of the Device that we are acknowledging. More...

std::string getDeviceName ()
 Return the name of the device that we are acknowledging. More...

std::string getDeviceBaseType ()
 Return the basetype of the device that we are acknowledging. More...

std::string getHostname ()
 Return the hostname of the node that is acknowledging the DeviceRequest. More...

bool getAck ()
 Return a boolean determining if this is a positive(ACK) or a negative(NACK) responce. More...


Static Public Methods

vpr::Uint16 getPacketFactoryType ()
 Return the type of this packet. More...


Constructor & Destructor Documentation

cluster::DeviceAck::DeviceAck   [inline]
 

Definition at line 52 of file DeviceAck.h.

00053    {;}

cluster::DeviceAck::DeviceAck const vpr::GUID &    plugin_id,
const vpr::GUID &    id,
const std::string &    device_name,
const std::string &    device_base_type,
bool    ack
 

Create a DeviceAck packet to acknowledge a ApplicationDataRequest.

Parameters:
plugin_guid  -GUID of the ClusterPlugin that should handle this packet.
id  -GUID of the Device that we are acknowledging.
device_name  -Name of the device that we are acknowledging.
device_base_type  -Basetype of the device that we are acknowledging.
ack  -Boolean determining if this is a positive(ACK) or a negative(NACK) responce.

Definition at line 43 of file DeviceAck.cpp.

References cluster::Packet::mHeader, cluster::Packet::mPluginId, and serialize.

00046    {
00047       // Set the local member variables using the given values.
00048       mPluginId = plugin_id;
00049       mId = id;
00050       mDeviceName = device_name;
00051       mDeviceBaseType = device_base_type;
00052       mAck = ack;
00053       
00054       // Get the localhost name.
00055       vpr::InetAddr local;
00056       vpr::InetAddr::getLocalHost(local);
00057          
00058       mHostname = local.getHostname();
00059       
00060       // Create a Header for this packet with the correect type and size.
00061       mHeader = new Header(Header::RIM_PACKET,
00062                                       Header::RIM_DEVICE_ACK,
00063                                       Header::RIM_PACKET_HEAD_SIZE 
00064                                       + 16 /*mPluginId*/
00065                                       + 16 /*mId*/
00066                                       + 2 /*value of size*/+ mDeviceName.size() /*length of mDeviceName*/
00067                                       + 2 /*value of size*/+ mDeviceBaseType.size() /*length of mDeviceBaseType*/
00068                                       + 2 /*value of size*/+ mHostname.size() /*length of mDeviceBaseType*/
00069                                       + 1 /*mAck*/,
00070                                       0/*Field not curently used*/);                      
00071       // Serialize the given data.
00072       serialize();
00073    }


Member Function Documentation

void cluster::DeviceAck::serialize  
 

Serializes member variables into a data stream.

Definition at line 75 of file DeviceAck.cpp.

References cluster::Packet::mHeader, cluster::Packet::mPacketWriter, and cluster::Packet::mPluginId.

Referenced by DeviceAck.

00076    {
00077       // Clear the data stream.
00078       mPacketWriter->getData()->clear();
00079       mPacketWriter->setCurPos(0);
00080 
00081       // Serialize the header.
00082       mHeader->serializeHeader();
00083       
00084       // Serialize plugin GUID
00085       mPluginId.writeObject(mPacketWriter);
00086       
00087       // Serialize Device GUID
00088       mId.writeObject(mPacketWriter);
00089       
00090       // Serialize the Device Name
00091       mPacketWriter->writeString(mDeviceName);
00092       
00093       // Serialize the Base Type of the acknowledged device
00094       mPacketWriter->writeString(mDeviceBaseType);
00095 
00096       // Serialize the hostname of the acknowledging node
00097       mPacketWriter->writeString(mHostname);
00098 
00099       // Serialize the Ack boolean
00100       mPacketWriter->writeBool(mAck);
00101    }

void cluster::DeviceAck::parse vpr::BufferObjectReader *    reader [virtual]
 

Parses the data stream into the local member variables.

Implements cluster::Packet.

Definition at line 103 of file DeviceAck.cpp.

References cluster::Packet::mPluginId.

00104    {
00105       // De-Serialize plugin GUID
00106       mPluginId.readObject(reader);
00107 
00108       // De-Serialize Device GUID
00109       mId.readObject(reader);
00110          
00111       // De-Serialize the Device Name
00112       mDeviceName = reader->readString();
00113 
00114       // De-Serialize the Base Type of the acknowledged device
00115       mDeviceBaseType = reader->readString();
00116 
00117       // De-Serialize the hostname of the acknowledging node
00118       mHostname = reader->readString();
00119 
00120       // De-Serialize the Ack boolean
00121       mAck = reader->readBool();
00122    }

void cluster::DeviceAck::printData int    debug_level [virtual]
 

Print the data to the screen in a readable form.

Implements cluster::Packet.

Definition at line 124 of file DeviceAck.cpp.

References gadgetDBG_RIM, and cluster::Packet::mPluginId.

00125    {
00126       vprDEBUG_BEGIN(gadgetDBG_RIM,debug_level) 
00127          <<  clrOutBOLD(clrYELLOW,"==== Device Ack Packet Data ====\n") << vprDEBUG_FLUSH;
00128       
00129       Packet::printData(debug_level);
00130 
00131       vprDEBUG(gadgetDBG_RIM,debug_level) 
00132          << clrOutBOLD(clrYELLOW, "Plugin GUID:      ") << mPluginId.toString()
00133          << std::endl << vprDEBUG_FLUSH;
00134       vprDEBUG(gadgetDBG_RIM,debug_level) 
00135          << clrOutBOLD(clrYELLOW, "Device ID:        ") << mId.toString()
00136          << std::endl << vprDEBUG_FLUSH;
00137       vprDEBUG(gadgetDBG_RIM,debug_level) 
00138          << clrOutBOLD(clrYELLOW, "Device Name:      ") << mDeviceName
00139          << std::endl << vprDEBUG_FLUSH;
00140       vprDEBUG(gadgetDBG_RIM,debug_level) 
00141          << clrOutBOLD(clrYELLOW, "Device Base Type: ") << mDeviceBaseType 
00142          << std::endl << vprDEBUG_FLUSH;
00143       vprDEBUG(gadgetDBG_RIM,debug_level) 
00144          << clrOutBOLD(clrYELLOW, "Remote Hostname:  ") << mHostname
00145          << std::endl << vprDEBUG_FLUSH;
00146       vprDEBUG(gadgetDBG_RIM,debug_level) 
00147          << clrOutBOLD(clrYELLOW, "Ack or Nack:      ") << (mAck ? "Ack" : "Nack")  << std::endl
00148          << std::endl << vprDEBUG_FLUSH;
00149 
00150       vprDEBUG_END(gadgetDBG_RIM,debug_level) 
00151          <<  clrOutBOLD(clrYELLOW,"================================\n") << vprDEBUG_FLUSH;
00152    }

vpr::Uint16 cluster::DeviceAck::getPacketFactoryType   [inline, static]
 

Return the type of this packet.

Definition at line 86 of file DeviceAck.h.

00087    {
00088        return(Header::RIM_DEVICE_ACK);
00089    }

vpr::GUID cluster::DeviceAck::getId   [inline]
 

Return the GUID of the Device that we are acknowledging.

Definition at line 94 of file DeviceAck.h.

00094 { return mId; }

std::string cluster::DeviceAck::getDeviceName   [inline]
 

Return the name of the device that we are acknowledging.

Definition at line 99 of file DeviceAck.h.

00099 { return mDeviceName; }

std::string cluster::DeviceAck::getDeviceBaseType   [inline]
 

Return the basetype of the device that we are acknowledging.

Definition at line 104 of file DeviceAck.h.

00104 { return mDeviceBaseType; }

std::string cluster::DeviceAck::getHostname   [inline]
 

Return the hostname of the node that is acknowledging the DeviceRequest.

Definition at line 109 of file DeviceAck.h.

00109 { return mHostname; }

bool cluster::DeviceAck::getAck   [inline]
 

Return a boolean determining if this is a positive(ACK) or a negative(NACK) responce.

Definition at line 114 of file DeviceAck.h.

00114 { return mAck; }


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