DeviceRequest.cpp

Go to the documentation of this file.
00001 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
00002  *
00003  * VR Juggler is (C) Copyright 1998-2005 by Iowa State University
00004  *
00005  * Original Authors:
00006  *   Allen Bierbaum, Christopher Just,
00007  *   Patrick Hartling, Kevin Meinert,
00008  *   Carolina Cruz-Neira, Albert Baker
00009  *
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Library General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2 of the License, or (at your option) any later version.
00014  *
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Library General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Library General Public
00021  * License along with this library; if not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00023  * Boston, MA 02111-1307, USA.
00024  *
00025  * -----------------------------------------------------------------
00026  * File:          $RCSfile$
00027  * Date modified: $Date: 2005-12-21 19:26:16 -0600 (Wed, 21 Dec 2005) $
00028  * Version:       $Revision: 18317 $
00029  * -----------------------------------------------------------------
00030  *
00031  *************** <auto-copyright.pl END do not edit this line> ***************/
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       // Set the local member variables using the given values.
00047       mDeviceName = device_name;
00048       mPluginId = plugin_guid;
00049       
00050       // Create a Header for this packet with the correect type and size.
00051       mHeader = new Header(Header::RIM_PACKET,
00052                                       Header::RIM_DEVICE_REQ,
00053                                       Header::RIM_PACKET_HEAD_SIZE 
00054                                       + 16 /*Plugin GUID*/
00055                                       + vpr::BufferObjectReader::STRING_LENGTH_SIZE
00056                                       + mDeviceName.size(),
00057                                       0/*Field not curently used*/);
00058       // Serialize the given data.
00059       serialize();
00060    }
00061 
00062    void DeviceRequest::serialize()
00063    {
00064       // Clear the data stream.
00065       mPacketWriter->getData()->clear();
00066       mPacketWriter->setCurPos(0);
00067 
00068       // Serialize the header.
00069       mHeader->serializeHeader();
00070       
00071       // Serialize plugin GUID.
00072       mPluginId.writeObject(mPacketWriter);
00073 
00074       // Serialize the name of the requested device.
00075       mPacketWriter->writeString(mDeviceName);
00076    }
00077    void DeviceRequest::parse(vpr::BufferObjectReader* reader)
00078    {   
00079       // De-Serialize plugin GUID
00080       mPluginId.readObject(reader);
00081 
00082       // De-Serialize the name of the requested device.
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 }   // end namespace gadget

Generated on Thu Jan 4 10:41:55 2007 for Gadgeteer by  doxygen 1.5.1