Panda3D
 All Classes Functions Variables Enumerations
asyncTaskSequence.h
1 // Filename: asyncTaskSequence.h
2 // Created by: drose (04Oct08)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef ASYNCTASKSEQUENCE_H
16 #define ASYNCTASKSEQUENCE_H
17 
18 #include "pandabase.h"
19 
20 #include "asyncTask.h"
21 #include "asyncTaskCollection.h"
22 
23 class AsyncTaskManager;
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : AsyncTaskSequence
27 // Description : A special kind of task that serves as a list of tasks
28 // internally. Each task on the list is executed in
29 // sequence, one per epoch.
30 //
31 // This is similar to a Sequence interval, though it has
32 // some slightly different abilities. For instance,
33 // although you can't start at any arbitrary point in
34 // the sequence, you can construct a task sequence whose
35 // duration changes during playback.
36 ////////////////////////////////////////////////////////////////////
37 class EXPCL_PANDA_EVENT AsyncTaskSequence : public AsyncTask, public AsyncTaskCollection {
38 PUBLISHED:
39  AsyncTaskSequence(const string &name);
40  virtual ~AsyncTaskSequence();
41  ALLOC_DELETED_CHAIN(AsyncTaskSequence);
42 
43  INLINE void set_repeat_count(int repeat_count);
44  INLINE int get_repeat_count() const;
45 
46  INLINE int get_current_task_index() const;
47 
48 protected:
49  virtual bool is_runnable();
50  virtual DoneStatus do_task();
51  virtual void upon_birth(AsyncTaskManager *manager);
52  virtual void upon_death(AsyncTaskManager *manager, bool clean_exit);
53 
54 private:
55  void set_current_task(AsyncTask *task, bool clean_exit);
56 
57  int _repeat_count;
58  int _task_index;
59  PT(AsyncTask) _current_task;
60 
61 public:
62  static TypeHandle get_class_type() {
63  return _type_handle;
64  }
65  static void init_type() {
66  AsyncTask::init_type();
67  register_type(_type_handle, "AsyncTaskSequence",
68  AsyncTask::get_class_type());
69  }
70  virtual TypeHandle get_type() const {
71  return get_class_type();
72  }
73  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
74 
75 private:
76  static TypeHandle _type_handle;
77 };
78 
79 #include "asyncTaskSequence.I"
80 
81 #endif
82 
A class to manage a loose queue of isolated tasks, which can be performed either synchronously (in th...
A list of tasks, for instance as returned by some of the AsyncTaskManager query functions.
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:43
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85