Panda3D
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 
20 class BamReader;
21 class BamWriter;
22 class Datagram;
23 class DatagramIterator;
24 class 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  */
46 class EXPCL_PANDA_RECORDER RecorderBase {
47 protected:
48  RecorderBase();
49 
50 PUBLISHED:
51  virtual ~RecorderBase();
52 
53  INLINE bool is_recording() const;
54  INLINE bool is_playing() const;
55 
56 public:
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 
68 protected:
69  void fillin_recorder(DatagramIterator &scan, BamReader *manager);
70 
71 private:
72  enum Flags {
73  F_recording = 0x0001,
74  F_playing = 0x0002,
75  };
76  short _flags;
77 
78 public:
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 
91 private:
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
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
This object is used by the RecorderController to write (and read) a record of the set of recorders in...
Definition: recorderTable.h:32
This is the base class to a number of objects that record particular kinds of user input (like a Mous...
Definition: recorderBase.h:46
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:81
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38