Panda3D
Loading...
Searching...
No Matches
asyncTaskSequence.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 asyncTaskSequence.h
10 * @author drose
11 * @date 2008-10-04
12 */
13
14#ifndef ASYNCTASKSEQUENCE_H
15#define ASYNCTASKSEQUENCE_H
16
17#include "pandabase.h"
18
19#include "asyncTask.h"
20#include "asyncTaskCollection.h"
21
23
24/**
25 * A special kind of task that serves as a list of tasks internally. Each
26 * task on the list is executed in sequence, one per epoch.
27 *
28 * This is similar to a Sequence interval, though it has some slightly
29 * different abilities. For instance, although you can't start at any
30 * arbitrary point in the sequence, you can construct a task sequence whose
31 * duration changes during playback.
32 */
33class EXPCL_PANDA_EVENT AsyncTaskSequence : public AsyncTask, public AsyncTaskCollection {
34PUBLISHED:
35 explicit AsyncTaskSequence(const std::string &name);
36 virtual ~AsyncTaskSequence();
37 ALLOC_DELETED_CHAIN(AsyncTaskSequence);
38
39 INLINE void set_repeat_count(int repeat_count);
40 INLINE int get_repeat_count() const;
41
42 INLINE size_t get_current_task_index() const;
43
44protected:
45 virtual bool is_runnable();
46 virtual DoneStatus do_task();
47 virtual void upon_birth(AsyncTaskManager *manager);
48 virtual void upon_death(AsyncTaskManager *manager, bool clean_exit);
49
50private:
51 void set_current_task(AsyncTask *task, bool clean_exit);
52
53 int _repeat_count;
54 size_t _task_index;
55 PT(AsyncTask) _current_task;
56
57public:
58 static TypeHandle get_class_type() {
59 return _type_handle;
60 }
61 static void init_type() {
62 AsyncTask::init_type();
63 register_type(_type_handle, "AsyncTaskSequence",
64 AsyncTask::get_class_type());
65 }
66 virtual TypeHandle get_type() const {
67 return get_class_type();
68 }
69 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
70
71private:
72 static TypeHandle _type_handle;
73};
74
75#include "asyncTaskSequence.I"
76
77#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A list of tasks, for instance as returned by some of the AsyncTaskManager query functions.
A class to manage a loose queue of isolated tasks, which can be performed either synchronously (in th...
A special kind of task that serves as a list of tasks internally.
This class represents a concrete task performed by an AsyncManager.
Definition asyncTask.h:32
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...