00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CINTERVALMANAGER_H
00016 #define CINTERVALMANAGER_H
00017
00018 #include "directbase.h"
00019 #include "cInterval.h"
00020 #include "pointerTo.h"
00021 #include "pvector.h"
00022 #include "pmap.h"
00023 #include "vector_int.h"
00024 #include "pmutex.h"
00025
00026 class EventQueue;
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 class EXPCL_DIRECT CIntervalManager {
00044 PUBLISHED:
00045 CIntervalManager();
00046 ~CIntervalManager();
00047
00048 INLINE void set_event_queue(EventQueue *event_queue);
00049 INLINE EventQueue *get_event_queue() const;
00050
00051 int add_c_interval(CInterval *interval, bool external);
00052 int find_c_interval(const string &name) const;
00053
00054 CInterval *get_c_interval(int index) const;
00055 void remove_c_interval(int index);
00056
00057 int interrupt();
00058 int get_num_intervals() const;
00059 int get_max_index() const;
00060
00061 void step();
00062 int get_next_event();
00063 int get_next_removal();
00064
00065 void output(ostream &out) const;
00066 void write(ostream &out) const;
00067
00068 static CIntervalManager *get_global_ptr();
00069
00070 private:
00071 void finish_interval(CInterval *interval);
00072 void remove_index(int index);
00073
00074 enum Flags {
00075 F_external = 0x0001,
00076 F_meta_interval = 0x0002,
00077 };
00078 class IntervalDef {
00079 public:
00080 PT(CInterval) _interval;
00081 int _flags;
00082 int _next_slot;
00083 };
00084 typedef pvector<IntervalDef> Intervals;
00085 Intervals _intervals;
00086 typedef pmap<string, int> NameIndex;
00087 NameIndex _name_index;
00088 typedef vector_int Removed;
00089 Removed _removed;
00090 EventQueue *_event_queue;
00091
00092 int _first_slot;
00093 int _next_event_index;
00094
00095 Mutex _lock;
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