root/juggler/branches/2.2/modules/gadgeteer/cluster/Packets/DeviceRequest.cpp

Revision 19729, 3.6 kB (checked in by patrick, 2 years ago)

Copyright update.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
2  *
3  * VR Juggler is (C) Copyright 1998-2007 by Iowa State University
4  *
5  * Original Authors:
6  *   Allen Bierbaum, Christopher Just,
7  *   Patrick Hartling, Kevin Meinert,
8  *   Carolina Cruz-Neira, Albert Baker
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public
21  * License along with this library; if not, write to the
22  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23  * Boston, MA 02111-1307, USA.
24  *
25  *************** <auto-copyright.pl END do not edit this line> ***************/
26
27 #include <boost/concept_check.hpp>
28
29 #include <gadget/Util/Debug.h>
30
31 #include <cluster/Packets/DeviceRequest.h>
32 #include <cluster/Packets/PacketFactory.h>
33
34 namespace cluster
35 {
36    CLUSTER_REGISTER_CLUSTER_PACKET_CREATOR(DeviceRequest);   
37    
38    DeviceRequest::DeviceRequest(const vpr::GUID& plugin_guid, const std::string& device_name)
39    {
40       // Set the local member variables using the given values.
41       mDeviceName = device_name;
42       mPluginId = plugin_guid;
43      
44       // Create a Header for this packet with the correect type and size.
45       mHeader = new Header(Header::RIM_PACKET,
46                                       Header::RIM_DEVICE_REQ,
47                                       Header::RIM_PACKET_HEAD_SIZE
48                                       + 16 /*Plugin GUID*/
49                                       + vpr::BufferObjectReader::STRING_LENGTH_SIZE
50                                       + mDeviceName.size(),
51                                       0/*Field not curently used*/);
52       // Serialize the given data.
53       serialize();
54    }
55
56    void DeviceRequest::serialize()
57    {
58       // Clear the data stream.
59       mPacketWriter->getData()->clear();
60       mPacketWriter->setCurPos(0);
61
62       // Serialize the header.
63       mHeader->serializeHeader();
64      
65       // Serialize plugin GUID.
66       mPluginId.writeObject(mPacketWriter);
67
68       // Serialize the name of the requested device.
69       mPacketWriter->writeString(mDeviceName);
70    }
71    void DeviceRequest::parse(vpr::BufferObjectReader* reader)
72    {   
73       // De-Serialize plugin GUID
74       mPluginId.readObject(reader);
75
76       // De-Serialize the name of the requested device.
77       mDeviceName = reader->readString();
78    }
79    
80    void DeviceRequest::printData(int debug_level)
81    {
82       vprDEBUG_BEGIN(gadgetDBG_RIM,debug_level)
83          <<  clrOutBOLD(clrYELLOW,"==== Device Request Packet Data ====\n") << vprDEBUG_FLUSH;
84      
85       Packet::printData(debug_level);
86
87       vprDEBUG(gadgetDBG_RIM,debug_level)
88          << clrOutBOLD(clrYELLOW, "Plugin GUID: ") << mPluginId.toString()
89          << std::endl << vprDEBUG_FLUSH;
90       vprDEBUG(gadgetDBG_RIM,debug_level)
91          << clrOutBOLD(clrYELLOW, "Device Name: ") << mDeviceName
92          << std::endl << vprDEBUG_FLUSH;
93
94       vprDEBUG_END(gadgetDBG_RIM,debug_level)
95          <<  clrOutBOLD(clrYELLOW,"====================================\n") << vprDEBUG_FLUSH;
96    }                                                                                         
97 }   // end namespace gadget
98
Note: See TracBrowser for help on using the browser.