Panda3D

cIntervalManager.h
Go to the documentation of this file.
1 /**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file cIntervalManager.h
10 * @author drose
11 * @date 2002-09-10
12 */
13
14 #ifndef CINTERVALMANAGER_H
15 #define CINTERVALMANAGER_H
16
17 #include "directbase.h"
18 #include "cInterval.h"
19 #include "pointerTo.h"
20 #include "pvector.h"
21 #include "pmap.h"
22 #include "vector_int.h"
23 #include "pmutex.h"
24
25 class EventQueue;
26
27 /**
28 * This object holds a number of currently-playing intervals and is
29 * responsible for advancing them each frame as needed.
30 *
31 * There is normally only one IntervalManager object in the world, and it is
32 * the responsibility of the scripting language to call step() on this object
33 * once each frame, and to then process the events indicated by
34 * get_next_event().
35 *
36 * It is also possible to create multiple IntervalManager objects for special
37 * needs.
38 */
39 class EXPCL_DIRECT_INTERVAL CIntervalManager {
40 PUBLISHED:
41 CIntervalManager();
42 ~CIntervalManager();
43
44 INLINE void set_event_queue(EventQueue *event_queue);
45 INLINE EventQueue *get_event_queue() const;
46
47 int add_c_interval(CInterval *interval, bool external);
48 int find_c_interval(const std::string &name) const;
49
50 CInterval *get_c_interval(int index) const;
51 void remove_c_interval(int index);
52
53 int interrupt();
54 int get_num_intervals() const;
55 int get_max_index() const;
56
57 void step();
58 int get_next_event();
59 int get_next_removal();
60
61 void output(std::ostream &out) const;
62 void write(std::ostream &out) const;
63
64 static CIntervalManager *get_global_ptr();
65
66 private:
67 void finish_interval(CInterval *interval);
68 void remove_index(int index);
69
70 enum Flags {
71 F_external = 0x0001,
72 F_meta_interval = 0x0002,
73 };
74 class IntervalDef {
75 public:
76 PT(CInterval) _interval;
77 int _flags;
78 int _next_slot;
79 };
80 typedef pvector<IntervalDef> Intervals;
81 Intervals _intervals;
82 typedef pmap<std::string, int> NameIndex;
83 NameIndex _name_index;
84 typedef vector_int Removed;
85 Removed _removed;
86 EventQueue *_event_queue;
87
88 int _first_slot;
89 int _next_event_index;
90
91 Mutex _lock;
92
93 static CIntervalManager *_global_ptr;
94 };
95
96 INLINE std::ostream &operator << (std::ostream &out, const CInterval &ival_mgr);
97
98 #include "cIntervalManager.I"
99
100 #endif
cIntervalManager.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
cInterval.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CIntervalManager
This object holds a number of currently-playing intervals and is responsible for advancing them each ...
Definition: cIntervalManager.h:39
CInterval
The base class for timeline components.
Definition: cInterval.h:36
EventQueue
A queue of pending events.
Definition: eventQueue.h:29
Mutex
A standard mutex, or mutual exclusion lock.
Definition: pmutex.h:40
pmap< std::string, int >
pvector< IntervalDef >
directbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pmap.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pmutex.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pvector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
vector_int.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.