Panda3D
Loading...
Searching...
No Matches
recorderBase.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 recorderBase.h
10 * @author drose
11 * @date 2004-01-25
12 */
13
14#ifndef RECORDERBASE_H
15#define RECORDERBASE_H
16
17#include "pandabase.h"
18#include "referenceCount.h"
19
20class BamReader;
21class BamWriter;
22class Datagram;
24class TypedWritable;
25
26/**
27 * This is the base class to a number of objects that record particular kinds
28 * of user input (like a MouseRecorder) to use in conjunction with a
29 * RecorderController to record the user's inputs for a session.
30 *
31 * Note that RecorderBase does not actually inherit from TypedObject, even
32 * though it defines get_type(). The assumption is that the classes that
33 * derive from RecorderBase might also inherit independently from TypedObject.
34 *
35 * It also does not inherit from TypedWritable, but it defines a method called
36 * write_recorder() which is very similar to a TypedWritable's
37 * write_datagram(). Classes that derive from RecorderBase and also inherit
38 * from TypedWritable may choose to remap write_recorder() to do exactly the
39 * same thing as write_datagram(), or they may choose to write something
40 * slightly different.
41 *
42 * Most types of recorders should derive from Recorder, as it derives from
43 * ReferenceCount, except for MouseRecorder, which would otherwise doubly
44 * inherit from ReferenceCount.
45 */
46class EXPCL_PANDA_RECORDER RecorderBase {
47protected:
48 RecorderBase();
49
50PUBLISHED:
51 virtual ~RecorderBase();
52
53 INLINE bool is_recording() const;
54 INLINE bool is_playing() const;
55
56public:
57 virtual void record_frame(BamWriter *manager, Datagram &dg);
58 virtual void play_frame(DatagramIterator &scan, BamReader *manager);
59
60 virtual void write_recorder(BamWriter *manager, Datagram &dg);
61
62 // We can't let RecorderBase inherit from ReferenceCount, so we define these
63 // so we can still manage the reference count.
64 virtual int get_ref_count() const=0;
65 virtual void ref() const=0;
66 virtual bool unref() const=0;
67
68protected:
69 void fillin_recorder(DatagramIterator &scan, BamReader *manager);
70
71private:
72 enum Flags {
73 F_recording = 0x0001,
74 F_playing = 0x0002,
75 };
76 short _flags;
77
78public:
79 static TypeHandle get_class_type() {
80 return _type_handle;
81 }
82 static void init_type() {
83 ReferenceCount::init_type();
84 register_type(_type_handle, "RecorderBase",
85 ReferenceCount::get_class_type());
86 }
87 virtual TypeHandle get_type() const {
88 return get_class_type();
89 }
90
91private:
92 static TypeHandle _type_handle;
93
94 friend class RecorderController;
95 friend class RecorderTable;
96};
97
98#include "recorderBase.I"
99
100#endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
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.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
bool is_playing() const
Returns true if this recorder is presently playing back data from session file, false otherwise.
bool is_recording() const
Returns true if this recorder is presently recording data for saving to a session file,...
virtual void write_recorder(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for encoding in the session file.
virtual void play_frame(DatagramIterator &scan, BamReader *manager)
Reloads the most recent data collected from the indicated datagram.
virtual void record_frame(BamWriter *manager, Datagram &dg)
Records the most recent data collected into the indicated datagram.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...