Panda3D

recorderTable.h

00001 // Filename: recorderTable.h
00002 // Created by:  drose (27Jan04)
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 RECORDERTABLE_H
00016 #define RECORDERTABLE_H
00017 
00018 #include "pandabase.h"
00019 #include "recorderBase.h"
00020 #include "pointerTo.h"
00021 #include "pmap.h"
00022 #include "typedWritable.h"
00023 
00024 class BamWriter;
00025 class BamReader;
00026 class FactoryParams;
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //       Class : RecorderTable
00030 // Description : This object is used by the RecorderController to
00031 //               write (and read) a record of the set of recorders in
00032 //               use to the bam file.  Do not attempt to use it
00033 //               directly.
00034 ////////////////////////////////////////////////////////////////////
00035 class EXPCL_PANDA_RECORDER RecorderTable : public TypedWritable {
00036 public:
00037   INLINE RecorderTable();
00038   INLINE RecorderTable(const RecorderTable &copy);
00039   INLINE void operator = (const RecorderTable &copy);
00040   INLINE ~RecorderTable();
00041 
00042   void merge_from(const RecorderTable &other);
00043 
00044   void add_recorder(const string &name, RecorderBase *recorder);
00045   RecorderBase *get_recorder(const string &name) const;
00046   bool remove_recorder(const string &name);
00047 
00048   void write(ostream &out, int indent_level) const;
00049 
00050 
00051   typedef pmap<string, PT(RecorderBase) > Recorders;
00052   Recorders _recorders;
00053 
00054   bool _error;
00055 
00056 public:
00057   static void register_with_read_factory();
00058   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00059 
00060 protected:
00061   static TypedWritable *make_from_bam(const FactoryParams &params);
00062   void fillin(DatagramIterator &scan, BamReader *manager);
00063   
00064 public:
00065   static TypeHandle get_class_type() {
00066     return _type_handle;
00067   }
00068   static void init_type() {
00069     TypedWritable::init_type();
00070     register_type(_type_handle, "RecorderTable",
00071                   TypedWritable::get_class_type());
00072   }
00073   virtual TypeHandle get_type() const {
00074     return get_class_type();
00075   }
00076   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00077 
00078 private:
00079   static TypeHandle _type_handle;
00080 };
00081 
00082 #include "recorderTable.I"
00083 
00084 #endif
00085 
 All Classes Functions Variables Enumerations