Panda3D
recorderBase.h
1 // Filename: recorderBase.h
2 // Created by: drose (25Jan04)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef RECORDERBASE_H
16 #define RECORDERBASE_H
17 
18 #include "pandabase.h"
19 #include "referenceCount.h"
20 
21 class BamReader;
22 class BamWriter;
23 class Datagram;
24 class DatagramIterator;
25 class TypedWritable;
26 
27 ////////////////////////////////////////////////////////////////////
28 // Class : RecorderBase
29 // Description : This is the base class to a number of objects that
30 // record particular kinds of user input (like a
31 // MouseRecorder) to use in conjunction with a
32 // RecorderController to record the user's inputs
33 // for a session.
34 //
35 // Note that RecorderBase does not actually inherit from
36 // TypedObject, even though it defines get_type(). The
37 // assumption is that the classes that derive from
38 // RecorderBase might also inherit independently from
39 // TypedObject.
40 //
41 // It also does not inherit from TypedWritable, but it
42 // defines a method called write_recorder() which is
43 // very similar to a TypedWritable's write_datagram().
44 // Classes that derive from RecorderBase and also
45 // inherit from TypedWritable may choose to remap
46 // write_recorder() to do exactly the same thing as
47 // write_datagram(), or they may choose to write
48 // something slightly different.
49 //
50 // Most types of recorders should derive from Recorder,
51 // as it derives from ReferenceCount, except for
52 // MouseRecorder, which would otherwise doubly inherit
53 // from ReferenceCount.
54 ////////////////////////////////////////////////////////////////////
55 class EXPCL_PANDA_RECORDER RecorderBase {
56 protected:
57  RecorderBase();
58 
59 PUBLISHED:
60  virtual ~RecorderBase();
61 
62  INLINE bool is_recording() const;
63  INLINE bool is_playing() const;
64 
65 public:
66  virtual void record_frame(BamWriter *manager, Datagram &dg);
67  virtual void play_frame(DatagramIterator &scan, BamReader *manager);
68 
69  virtual void write_recorder(BamWriter *manager, Datagram &dg);
70 
71  // We can't let RecorderBase inherit from ReferenceCount, so we
72  // define these so we can still manage the reference count.
73  virtual void ref() const=0;
74  virtual bool unref() const=0;
75 
76 protected:
77  void fillin_recorder(DatagramIterator &scan, BamReader *manager);
78 
79 private:
80  enum Flags {
81  F_recording = 0x0001,
82  F_playing = 0x0002,
83  };
84  short _flags;
85 
86 public:
87  static TypeHandle get_class_type() {
88  return _type_handle;
89  }
90  static void init_type() {
91  ReferenceCount::init_type();
92  register_type(_type_handle, "RecorderBase",
93  ReferenceCount::get_class_type());
94  }
95  virtual TypeHandle get_type() const {
96  return get_class_type();
97  }
98 
99 private:
100  static TypeHandle _type_handle;
101 
102  friend class RecorderController;
103  friend class RecorderTable;
104 };
105 
106 #include "recorderBase.I"
107 
108 #endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
This object is used by the RecorderController to write (and read) a record of the set of recorders in...
Definition: recorderTable.h:35
This is the base class to a number of objects that record particular kinds of user input (like a Mous...
Definition: recorderBase.h:55
This object manages the process of recording the user's runtime inputs to a bam file so that the sess...
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43