Panda3D

recorderHeader.cxx

00001 // Filename: recorderHeader.cxx
00002 // Created by:  drose (29Jan04)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "recorderHeader.h"
00016 #include "recorderTable.h"
00017 #include "bamReader.h"
00018 #include "bamWriter.h"
00019 #include "config_recorder.h"
00020 
00021 TypeHandle RecorderHeader::_type_handle;
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //     Function: RecorderHeader::register_with_read_factory
00025 //       Access: Public, Static
00026 //  Description: Tells the BamReader how to create objects of type
00027 //               Lens.
00028 ////////////////////////////////////////////////////////////////////
00029 void RecorderHeader::
00030 register_with_read_factory() {
00031   BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
00032 }
00033 
00034 ////////////////////////////////////////////////////////////////////
00035 //     Function: RecorderHeader::write_datagram
00036 //       Access: Public, Virtual
00037 //  Description: Writes the contents of this object to the datagram
00038 //               for shipping out to a Bam file.
00039 ////////////////////////////////////////////////////////////////////
00040 void RecorderHeader::
00041 write_datagram(BamWriter *manager, Datagram &dg) {
00042   TypedWritable::write_datagram(manager, dg);
00043   
00044   // One day this will need to be upgraded to a uint64, but probably
00045   // not before 2106.  (In 2038, Unix time will overflow a signed
00046   // 32-bit number, but this is an unsigned number and will still be
00047   // good until 2106.)
00048   dg.add_uint32(_start_time);
00049 
00050   dg.add_int32(_random_seed);
00051 }
00052 
00053 ////////////////////////////////////////////////////////////////////
00054 //     Function: RecorderHeader::make_from_bam
00055 //       Access: Protected, Static
00056 //  Description: This function is called by the BamReader's factory
00057 //               when a new object of type Lens is encountered
00058 //               in the Bam file.  It should create the Lens
00059 //               and extract its information from the file.
00060 ////////////////////////////////////////////////////////////////////
00061 TypedWritable *RecorderHeader::
00062 make_from_bam(const FactoryParams &params) {
00063   RecorderHeader *header = new RecorderHeader;
00064   DatagramIterator scan;
00065   BamReader *manager;
00066 
00067   parse_params(params, scan, manager);
00068   header->fillin(scan, manager);
00069 
00070   return header;
00071 }
00072 
00073 ////////////////////////////////////////////////////////////////////
00074 //     Function: RecorderHeader::fillin
00075 //       Access: Protected
00076 //  Description: This internal function is called by make_from_bam to
00077 //               read in all of the relevant data from the BamFile for
00078 //               the new RecorderHeader.
00079 ////////////////////////////////////////////////////////////////////
00080 void RecorderHeader::
00081 fillin(DatagramIterator &scan, BamReader *manager) {
00082   TypedWritable::fillin(scan, manager);
00083 
00084   _start_time = scan.get_uint32();
00085   _random_seed = scan.get_int32();
00086 }
 All Classes Functions Variables Enumerations