Panda3D

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:27
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
This object is used by the RecorderController to write (and read) a record of the set of recorders in...
Definition: recorderTable.h:32
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
TypedWritable
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
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
pmap< std::string, RecorderBase * >
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.