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

panda/src/pstatclient/pStatFrameData.cxx

Go to the documentation of this file.
00001 // Filename: pStatFrameData.cxx
00002 // Created by:  drose (10Jul00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "pStatFrameData.h"
00020 #include "pStatClientVersion.h"
00021 
00022 #include <datagram.h>
00023 #include <datagramIterator.h>
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //     Function: PStatFrameData::write_datagram
00027 //       Access: Public
00028 //  Description: Writes the definition of the FrameData to the
00029 //               datagram.
00030 ////////////////////////////////////////////////////////////////////
00031 void PStatFrameData::
00032 write_datagram(Datagram &destination) const {
00033   Data::const_iterator di;
00034   destination.add_uint16(_time_data.size());
00035   for (di = _time_data.begin(); di != _time_data.end(); ++di) {
00036     destination.add_uint16((*di)._index);
00037     destination.add_float32((*di)._value);
00038   }
00039   destination.add_uint16(_level_data.size());
00040   for (di = _level_data.begin(); di != _level_data.end(); ++di) {
00041     destination.add_uint16((*di)._index);
00042     destination.add_float32((*di)._value);
00043   }
00044 }
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //     Function: PStatFrameData::read_datagram
00048 //       Access: Public
00049 //  Description: Extracts the FrameData definition from the datagram.
00050 ////////////////////////////////////////////////////////////////////
00051 void PStatFrameData::
00052 read_datagram(DatagramIterator &source, PStatClientVersion *) {
00053   clear();
00054 
00055   int i;
00056   int time_size = source.get_uint16();
00057   for (i = 0; i < time_size; i++) {
00058     nassertv(source.get_remaining_size() > 0);
00059     DataPoint dp;
00060     dp._index = source.get_uint16();
00061     dp._value = source.get_float32();
00062     _time_data.push_back(dp);
00063   }
00064   int level_size = source.get_uint16();
00065   for (i = 0; i < level_size; i++) {
00066     nassertv(source.get_remaining_size() > 0);
00067     DataPoint dp;
00068     dp._index = source.get_uint16();
00069     dp._value = source.get_float32();
00070     _level_data.push_back(dp);
00071   }
00072   nassertv(source.get_remaining_size() == 0);
00073 }
00074 

Generated on Fri May 2 00:43:28 2003 for Panda by doxygen1.3