Panda3D
 All Classes Functions Variables Enumerations
recorderTable.h
1 // Filename: recorderTable.h
2 // Created by: drose (27Jan04)
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 RECORDERTABLE_H
16 #define RECORDERTABLE_H
17 
18 #include "pandabase.h"
19 #include "recorderBase.h"
20 #include "pointerTo.h"
21 #include "pmap.h"
22 #include "typedWritable.h"
23 
24 class BamWriter;
25 class BamReader;
26 class FactoryParams;
27 
28 ////////////////////////////////////////////////////////////////////
29 // Class : RecorderTable
30 // Description : This object is used by the RecorderController to
31 // write (and read) a record of the set of recorders in
32 // use to the bam file. Do not attempt to use it
33 // directly.
34 ////////////////////////////////////////////////////////////////////
35 class EXPCL_PANDA_RECORDER RecorderTable : public TypedWritable {
36 public:
37  INLINE RecorderTable();
38  INLINE RecorderTable(const RecorderTable &copy);
39  INLINE void operator = (const RecorderTable &copy);
40  ~RecorderTable();
41 
42  void merge_from(const RecorderTable &other);
43 
44  INLINE void add_recorder(const string &name, RecorderBase *recorder);
45  INLINE RecorderBase *get_recorder(const string &name) const;
46  INLINE bool remove_recorder(const string &name);
47 
48  void record_frame(BamWriter *manager, Datagram &dg);
49  void play_frame(DatagramIterator &scan, BamReader *manager);
50  void set_flags(short flags);
51  void clear_flags(short flags);
52 
53  void write(ostream &out, int indent_level) const;
54 
55  // RecorderBase itself doesn't inherit from ReferenceCount, so
56  // we can't put a PT() around it. Instead, we manage the reference
57  // count using calls to ref() and unref().
59  Recorders _recorders;
60 
61  bool _error;
62 
63 public:
64  static void register_with_read_factory();
65  virtual void write_datagram(BamWriter *manager, Datagram &dg);
66 
67 protected:
68  static TypedWritable *make_from_bam(const FactoryParams &params);
69  void fillin(DatagramIterator &scan, BamReader *manager);
70 
71 public:
72  static TypeHandle get_class_type() {
73  return _type_handle;
74  }
75  static void init_type() {
76  TypedWritable::init_type();
77  register_type(_type_handle, "RecorderTable",
78  TypedWritable::get_class_type());
79  }
80  virtual TypeHandle get_type() const {
81  return get_class_type();
82  }
83  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
84 
85 private:
86  static TypeHandle _type_handle;
87 };
88 
89 #include "recorderTable.I"
90 
91 #endif
92 
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
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...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
This object is used by the RecorderController to write (and read) a record of the set of recorders in...
Definition: recorderTable.h:35
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
This is the base class to a number of objects that record particular kinds of user input (like a Mous...
Definition: recorderBase.h:55
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