Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

direct/src/interval/cIntervalManager.h

Go to the documentation of this file.
00001 // Filename: cIntervalManager.h
00002 // Created by:  drose (10Sep02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef CINTERVALMANAGER_H
00020 #define CINTERVALMANAGER_H
00021 
00022 #include "directbase.h"
00023 #include "cInterval.h"
00024 #include "pointerTo.h"
00025 #include "pvector.h"
00026 #include "pmap.h"
00027 #include "vector_int.h"
00028 
00029 class EventQueue;
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //       Class : CIntervalManager
00033 // Description : This object holds a number of currently-playing
00034 //               intervals and is responsible for advancing them each
00035 //               frame as needed.
00036 //
00037 //               There is normally only one IntervalManager object in
00038 //               the world, and it is the responsibility of the
00039 //               scripting language to call step() on this object once
00040 //               each frame, and to then process the events indicated by
00041 //               get_next_event().  
00042 //
00043 //               It is also possible to create multiple
00044 //               IntervalManager objects for special needs.
00045 ////////////////////////////////////////////////////////////////////
00046 class EXPCL_DIRECT CIntervalManager {
00047 PUBLISHED:
00048   CIntervalManager();
00049   ~CIntervalManager();
00050 
00051   INLINE void set_event_queue(EventQueue *event_queue);
00052   INLINE EventQueue *get_event_queue() const;
00053 
00054   int add_c_interval(CInterval *interval, bool external);
00055   int find_c_interval(const string &name) const;
00056 
00057   CInterval *get_c_interval(int index) const;
00058   void remove_c_interval(int index);
00059 
00060   int interrupt();
00061   int get_num_intervals() const;
00062 
00063   void step();
00064   int get_next_event();
00065   int get_next_removal();
00066 
00067   void output(ostream &out) const;
00068   void write(ostream &out) const;
00069 
00070   static CIntervalManager *get_global_ptr();
00071 
00072 private:
00073   void finish_interval(CInterval *interval);
00074   void remove_index(int index);
00075 
00076   enum Flags {
00077     F_external      = 0x0001,
00078     F_meta_interval = 0x0002,
00079   };
00080   class IntervalDef {
00081   public:
00082     PT(CInterval) _interval;
00083     int _flags;
00084     int _next_slot;
00085   };
00086   typedef pvector<IntervalDef> Intervals;
00087   Intervals _intervals;
00088   typedef pmap<string, int> NameIndex;
00089   NameIndex _name_index;
00090   typedef vector_int Removed;
00091   Removed _removed;
00092   EventQueue *_event_queue;
00093 
00094   int _first_slot;
00095   int _next_event_index;
00096 
00097   static CIntervalManager *_global_ptr;
00098 };
00099 
00100 INLINE ostream &operator << (ostream &out, const CInterval &ival_mgr);
00101 
00102 #include "cIntervalManager.I"
00103 
00104 #endif
00105 
00106 
00107 

Generated on Fri May 2 01:37:40 2003 for Direct by doxygen1.3