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

ConnectionRequest.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-2003 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: ConnectionRequest.cpp,v $
00027  * Date modified: $Date: 2003/06/19 15:14:07 $
00028  * Version:       $Revision: 1.5 $
00029  * -----------------------------------------------------------------
00030  *
00031  *************** <auto-copyright.pl END do not edit this line> ***************/
00032 
00033 #include <gadget/Util/Debug.h>
00034 #include <cluster/Packets/ConnectionRequest.h>
00035 #include <cluster/Packets/PacketFactory.h>
00036 
00037 namespace cluster
00038 {
00039    CLUSTER_REGISTER_CLUSTER_PACKET_CREATOR(ConnectionRequest);
00040 
00041    ConnectionRequest::ConnectionRequest(std::string host_name, vpr::Uint16 port)
00042    {
00043       // Set the local member variables using the given values.
00044       mHostname = host_name;
00045       mPort = port;
00046             
00047       // Create a Header for this packet with the correect type and size.
00048       mHeader = new Header(Header::RIM_PACKET,
00049                                       Header::RIM_CONNECTION_REQ,
00050                                       Header::RIM_PACKET_HEAD_SIZE 
00051                                       + 2 
00052                                       + mHostname.size()
00053                                       + 2 /*mPort*/
00054                                       ,0/*Field not curently used*/);
00055       // Serialize the given data.
00056       serialize();
00057    }
00058 
00059    void ConnectionRequest::serialize()
00060    {
00061       // Clear the data stream.
00062       mPacketWriter->getData()->clear();
00063       mPacketWriter->setCurPos(0);
00064 
00065       // Serialize the header.
00066       mHeader->serializeHeader();
00067       
00068       // Serialize the hostname of the requesting machine.
00069       mPacketWriter->writeString(mHostname);
00070                
00071       // Serialize the listening port of the requesting machine
00072       mPacketWriter->writeUint16(mPort);                  
00073    }
00074    
00075    void ConnectionRequest::parse(vpr::BufferObjectReader* reader)
00076    {
00077       // De-Serialize the hostname of the requesting machine.
00078       mHostname = reader->readString();
00079          
00080       // De-Serialize the listening port of the requesting machine
00081       mPort = reader->readUint16();
00082    }
00083 
00084    void ConnectionRequest::printData(int debug_level)
00085    {
00086       vprDEBUG_BEGIN(gadgetDBG_RIM,debug_level) 
00087          <<  clrOutBOLD(clrYELLOW,"==== Connection Request Packet Data ====\n") << vprDEBUG_FLUSH;
00088       
00089       Packet::printData(debug_level);
00090 
00091       vprDEBUG(gadgetDBG_RIM,debug_level) 
00092          << clrOutBOLD(clrYELLOW, "Host Name:    ") << mHostname
00093          << std::endl << vprDEBUG_FLUSH;
00094       vprDEBUG(gadgetDBG_RIM,debug_level) 
00095          << clrOutBOLD(clrYELLOW, "Port:         ") << mPort
00096          << std::endl << vprDEBUG_FLUSH;
00097 
00098       vprDEBUG_END(gadgetDBG_RIM,debug_level) 
00099          <<  clrOutBOLD(clrYELLOW,"========================================\n") << vprDEBUG_FLUSH;
00100    }
00101 }   // end namespace gadget

Generated on Sun May 2 14:25:14 2004 for Gadgeteer by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002