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

Revision 19729, 3.9 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 #include <cluster/Packets/ApplicationDataAck.h>
31 #include <cluster/Packets/PacketFactory.h>
32
33 namespace cluster
34 {
35    CLUSTER_REGISTER_CLUSTER_PACKET_CREATOR(ApplicationDataAck);
36    
37    ApplicationDataAck::ApplicationDataAck(const vpr::GUID& plugin_guid,
38                                           const vpr::GUID& id,
39                                           const bool ack)
40    {
41       // Set the local member variables using the given values.
42       mPluginId = plugin_guid;
43       mId = id;
44       mAck = ack;
45      
46       // Create a Header for this packet with the correect type and size.
47       mHeader = new Header(Header::RIM_PACKET,
48                                       Header::RIM_APPDATA_ACK,
49                                       Header::RIM_PACKET_HEAD_SIZE
50                                       + 16/*Plugin GUID*/
51                                       + 16/*Object GUID*/
52                                       + 1 /*mAck*/,
53                                       0/*Field not curently used*/);
54       // Serialize the given data.
55       serialize();
56    }
57    void ApplicationDataAck::serialize()
58    {
59       // Clear the data stream.
60       mPacketWriter->getData()->clear();
61       mPacketWriter->setCurPos(0);
62
63       // Serialize the header.
64       mHeader->serializeHeader();
65      
66       // Serialize plugin GUID
67       mPluginId.writeObject(mPacketWriter);
68
69       // Serialize ApplicationData object GUID
70       mId.writeObject(mPacketWriter);
71
72       // Serialize the Ack boolean
73       mPacketWriter->writeBool(mAck);
74    }
75
76    void ApplicationDataAck::parse(vpr::BufferObjectReader* reader)
77    {
78       // De-Serialize plugin GUID
79       mPluginId.readObject(reader);
80      
81       // De-Serialize ApplicationData object GUID
82       mId.readObject(reader);
83
84       // De-Serialize the Ack boolean
85       mAck = reader->readBool();
86    }
87
88    void ApplicationDataAck::printData(int debug_level)
89    {
90       vprDEBUG_BEGIN(gadgetDBG_RIM,debug_level)
91          <<  clrOutBOLD(clrYELLOW,"==== ApplicationData Ack Packet ====\n") << vprDEBUG_FLUSH;
92      
93       Packet::printData(debug_level);
94
95       vprDEBUG(gadgetDBG_RIM,debug_level)
96          << clrOutBOLD(clrYELLOW, "Plugin GUID:        ") << mPluginId.toString()
97          << std::endl << vprDEBUG_FLUSH;
98       vprDEBUG(gadgetDBG_RIM,debug_level)
99          << clrOutBOLD(clrYELLOW, "Object GUID:        ") << mId.toString()
100          << std::endl << vprDEBUG_FLUSH;
101       vprDEBUG(gadgetDBG_RIM,debug_level)
102          << clrOutBOLD(clrYELLOW, "Ack or Nack:      ") << (mAck ? "Ack" : "Nack")  << std::endl
103          << std::endl << vprDEBUG_FLUSH;
104
105       vprDEBUG_END(gadgetDBG_RIM,debug_level)
106          <<  clrOutBOLD(clrYELLOW,"================================\n") << vprDEBUG_FLUSH;     
107    }
108
109 }   // end namespace gadget
110
Note: See TracBrowser for help on using the browser.