Panda3D
Loading...
Searching...
No Matches
recorderHeader.cxx
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file recorderHeader.cxx
10 * @author drose
11 * @date 2004-01-29
12 */
13
14#include "recorderHeader.h"
15#include "recorderTable.h"
16#include "bamReader.h"
17#include "bamWriter.h"
18#include "config_recorder.h"
19
20TypeHandle RecorderHeader::_type_handle;
21
22/**
23 * Tells the BamReader how to create objects of type Lens.
24 */
27 BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
28}
29
30/**
31 * Writes the contents of this object to the datagram for shipping out to a
32 * Bam file.
33 */
35write_datagram(BamWriter *manager, Datagram &dg) {
37
38 // One day this will need to be upgraded to a uint64, but probably not
39 // before 2106. (In 2038, Unix time will overflow a signed 32-bit number,
40 // but this is an unsigned number and will still be good until 2106.)
41 dg.add_uint32(_start_time);
42
43 dg.add_int32(_random_seed);
44}
45
46/**
47 * This function is called by the BamReader's factory when a new object of
48 * type Lens is encountered in the Bam file. It should create the Lens and
49 * extract its information from the file.
50 */
51TypedWritable *RecorderHeader::
52make_from_bam(const FactoryParams &params) {
53 RecorderHeader *header = new RecorderHeader;
55 BamReader *manager;
56
57 parse_params(params, scan, manager);
58 header->fillin(scan, manager);
59
60 return header;
61}
62
63/**
64 * This internal function is called by make_from_bam to read in all of the
65 * relevant data from the BamFile for the new RecorderHeader.
66 */
67void RecorderHeader::
68fillin(DatagramIterator &scan, BamReader *manager) {
69 TypedWritable::fillin(scan, manager);
70
71 _start_time = scan.get_uint32();
72 _random_seed = scan.get_int32();
73}
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams &params, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
Definition bamReader.I:275
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Definition bamReader.I:177
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
A class to retrieve the individual data elements previously stored in a Datagram.
uint32_t get_uint32()
Extracts an unsigned 32-bit integer.
int32_t get_int32()
Extracts a signed 32-bit integer.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
void add_uint32(uint32_t value)
Adds an unsigned 32-bit integer to the datagram.
Definition datagram.I:94
void add_int32(int32_t value)
Adds a signed 32-bit integer to the datagram.
Definition datagram.I:67
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
Definition factory.I:73
This object contains the header information written out at the beginning of a recorded session file.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
static void register_with_read_factory()
Tells the BamReader how to create objects of type Lens.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.