Panda3D

Loading...
Searching...
No Matches
recorderTable.h
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 recorderTable.h
10 * @author drose
11 * @date 2004-01-27
12 */
13
14#ifndef RECORDERTABLE_H
15#define RECORDERTABLE_H
16
17#include "pandabase.h"
18#include "recorderBase.h"
19#include "pointerTo.h"
20#include "pmap.h"
21#include "typedWritable.h"
22
23 class BamWriter;
24 class BamReader;
25 class FactoryParams;
26
27/**
28 * This object is used by the RecorderController to write (and read) a record
29 * of the set of recorders in use to the bam file. Do not attempt to use it
30 * directly.
31 */
32 class EXPCL_PANDA_RECORDER RecorderTable : public TypedWritable {
33 public:
34 INLINE RecorderTable();
35 INLINE RecorderTable(const RecorderTable &copy);
36 INLINE void operator = (const RecorderTable &copy);
37 ~RecorderTable();
38
39 void merge_from(const RecorderTable &other);
40
41 INLINE void add_recorder(const std::string &name, RecorderBase *recorder);
42 INLINE RecorderBase *get_recorder(const std::string &name) const;
43 INLINE bool remove_recorder(const std::string &name);
44
45 void record_frame(BamWriter *manager, Datagram &dg);
46 void play_frame(DatagramIterator &scan, BamReader *manager);
47 void set_flags(short flags);
48 void clear_flags(short flags);
49
50 void write(std::ostream &out, int indent_level) const;
51
52 // RecorderBase itself doesn't inherit from ReferenceCount, so we can't put
53 // a PT() around it. Instead, we manage the reference count using calls to
54 // ref() and unref().
55 typedef pmap<std::string, RecorderBase*> Recorders;
56 Recorders _recorders;
57
58 bool _error;
59
60 public:
61 static void register_with_read_factory();
62 virtual void write_datagram(BamWriter *manager, Datagram &dg);
63
64 protected:
65 static TypedWritable *make_from_bam(const FactoryParams &params);
66 void fillin(DatagramIterator &scan, BamReader *manager);
67
68 public:
69 static TypeHandle get_class_type() {
70 return _type_handle;
71 }
72 static void init_type() {
73 TypedWritable::init_type();
74 register_type(_type_handle, "RecorderTable",
75 TypedWritable::get_class_type());
76 }
77 virtual TypeHandle get_type() const {
78 return get_class_type();
79 }
80 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
81
82 private:
83 static TypeHandle _type_handle;
84};
85
86#include "recorderTable.I"
87
88#endif
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
BamWriter
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition datagramIterator.h:30
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition factoryParams.h:36
RecorderBase
This is the base class to a number of objects that record particular kinds of user input (like a Mous...
Definition recorderBase.h:46
RecorderTable::add_recorder
void add_recorder(const std::string &name, RecorderBase *recorder)
Adds the named recorder to the set of recorders.
Definition recorderTable.I:48
RecorderTable::record_frame
void record_frame(BamWriter *manager, Datagram &dg)
Calls record_frame on all recorders.
Definition recorderTable.cxx:89
RecorderTable::merge_from
void merge_from(const RecorderTable &other)
Combines the data in the current table (presumably just read from disk, and matching exactly with the...
Definition recorderTable.cxx:42
RecorderTable::register_with_read_factory
static void register_with_read_factory()
Tells the BamReader how to create objects of type Lens.
Definition recorderTable.cxx:162
RecorderTable::play_frame
void play_frame(DatagramIterator &scan, BamReader *manager)
Calls play_frame on all recorders.
Definition recorderTable.cxx:103
RecorderTable::remove_recorder
bool remove_recorder(const std::string &name)
Removes the named recorder from the table.
Definition recorderTable.I:80
RecorderTable::get_recorder
RecorderBase * get_recorder(const std::string &name) const
Returns the recorder with the indicated name, or NULL if there is no such recorder.
Definition recorderTable.I:67
RecorderTable::set_flags
void set_flags(short flags)
Sets the given flags on all recorders.
Definition recorderTable.cxx:117
RecorderTable::clear_flags
void clear_flags(short flags)
Clears the given flags on all recorders.
Definition recorderTable.cxx:131
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
TypedWritable::fillin
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...
Definition typedWritable.cxx:103
TypedWritable::write_datagram
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition typedWritable.cxx:54
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pmap.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
recorderBase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
recorderTable.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition register_type.I:22
typedWritable.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.