Panda3D
|
00001 // Filename: recorderBase.h 00002 // Created by: drose (25Jan04) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef RECORDERBASE_H 00016 #define RECORDERBASE_H 00017 00018 #include "pandabase.h" 00019 #include "referenceCount.h" 00020 00021 class BamReader; 00022 class BamWriter; 00023 class Datagram; 00024 class DatagramIterator; 00025 class TypedWritable; 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : RecorderBase 00029 // Description : This is the base class to a number of objects that 00030 // record particular kinds of user input (like a 00031 // MouseRecorder) to use in conjunction with a 00032 // RecorderController to record the user's inputs 00033 // for a session. 00034 // 00035 // Note that RecorderBase does not actually inherit from 00036 // TypedObject, even though it defines get_type(). The 00037 // assumption is that the classes that derive from 00038 // RecorderBase might also inherit independently from 00039 // TypedObject. 00040 // 00041 // It also does not inherit from TypedWritable, but it 00042 // defines a method called write_recorder() which is 00043 // very similar to a TypedWritable's write_datagram(). 00044 // Classes that derive from RecorderBase and also 00045 // inherit from TypedWritable may choose to remap 00046 // write_recorder() to do exactly the same thing as 00047 // write_datagram(), or they may choose to write 00048 // something slightly different. 00049 //////////////////////////////////////////////////////////////////// 00050 class EXPCL_PANDA_RECORDER RecorderBase : virtual public ReferenceCount { 00051 protected: 00052 RecorderBase(); 00053 00054 PUBLISHED: 00055 virtual ~RecorderBase(); 00056 00057 INLINE bool is_recording() const; 00058 INLINE bool is_playing() const; 00059 00060 public: 00061 virtual void record_frame(BamWriter *manager, Datagram &dg); 00062 virtual void play_frame(DatagramIterator &scan, BamReader *manager); 00063 00064 virtual void write_recorder(BamWriter *manager, Datagram &dg); 00065 00066 protected: 00067 void fillin_recorder(DatagramIterator &scan, BamReader *manager); 00068 00069 private: 00070 enum Flags { 00071 F_recording = 0x0001, 00072 F_playing = 0x0002, 00073 }; 00074 short _flags; 00075 00076 public: 00077 static TypeHandle get_class_type() { 00078 return _type_handle; 00079 } 00080 static void init_type() { 00081 ReferenceCount::init_type(); 00082 register_type(_type_handle, "RecorderBase", 00083 ReferenceCount::get_class_type()); 00084 } 00085 virtual TypeHandle get_type() const { 00086 return get_class_type(); 00087 } 00088 00089 private: 00090 static TypeHandle _type_handle; 00091 00092 friend class RecorderController; 00093 }; 00094 00095 #include "recorderBase.I" 00096 00097 #endif 00098