Panda3D

Loading...
Searching...
No Matches
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 {
40PUBLISHED:
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
96INLINE 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::find_c_interval
int find_c_interval(const std::string &name) const
Returns the index associated with the named interval, if there is such an interval,...
Definition cIntervalManager.cxx:111
CIntervalManager::get_next_event
int get_next_event()
This should be called by the scripting language after each call to step().
Definition cIntervalManager.cxx:297
CIntervalManager::remove_c_interval
void remove_c_interval(int index)
Removes the indicated interval from the queue immediately.
Definition cIntervalManager.cxx:138
CIntervalManager::get_num_intervals
int get_num_intervals() const
Returns the number of currently active intervals.
Definition cIntervalManager.cxx:227
CIntervalManager::step
void step()
This should be called every frame to do the processing for all the active intervals.
Definition cIntervalManager.cxx:257
CIntervalManager::interrupt
int interrupt()
Pauses or finishes (removes from the active queue) all intervals tagged with auto_pause or auto_finis...
Definition cIntervalManager.cxx:164
CIntervalManager::set_event_queue
void set_event_queue(EventQueue *event_queue)
Specifies a custom event queue to be used for throwing done events from intervals as they finish.
Definition cIntervalManager.I:24
CIntervalManager::get_global_ptr
static CIntervalManager * get_global_ptr()
Returns the pointer to the one global CIntervalManager object.
Definition cIntervalManager.cxx:397
CIntervalManager::get_c_interval
CInterval * get_c_interval(int index) const
Returns the interval associated with the given index.
Definition cIntervalManager.cxx:125
CIntervalManager::get_max_index
int get_max_index() const
Returns one more than the largest interval index number in the manager.
Definition cIntervalManager.cxx:240
CIntervalManager::get_next_removal
int get_next_removal()
This should be called by the scripting language after each call to step().
Definition cIntervalManager.cxx:332
CIntervalManager::get_event_queue
EventQueue * get_event_queue() const
Returns the custom event queue to be used for throwing done events from intervals as they finish.
Definition cIntervalManager.I:33
CIntervalManager::add_c_interval
int add_c_interval(CInterval *interval, bool external)
Adds the interval to the manager, and returns a unique index for the interval.
Definition cIntervalManager.cxx:54
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
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.