Panda3D
|
00001 // Filename: asyncTaskSequence.h 00002 // Created by: drose (04Oct08) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef ASYNCTASKSEQUENCE_H 00016 #define ASYNCTASKSEQUENCE_H 00017 00018 #include "pandabase.h" 00019 00020 #include "asyncTask.h" 00021 #include "asyncTaskCollection.h" 00022 00023 class AsyncTaskManager; 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : AsyncTaskSequence 00027 // Description : A special kind of task that serves as a list of tasks 00028 // internally. Each task on the list is executed in 00029 // sequence, one per epoch. 00030 // 00031 // This is similar to a Sequence interval, though it has 00032 // some slightly different abilities. For instance, 00033 // although you can't start at any arbitrary point in 00034 // the sequence, you can construct a task sequence whose 00035 // duration changes during playback. 00036 //////////////////////////////////////////////////////////////////// 00037 class EXPCL_PANDA_EVENT AsyncTaskSequence : public AsyncTask, public AsyncTaskCollection { 00038 PUBLISHED: 00039 AsyncTaskSequence(const string &name); 00040 virtual ~AsyncTaskSequence(); 00041 ALLOC_DELETED_CHAIN(AsyncTaskSequence); 00042 00043 INLINE void set_repeat_count(int repeat_count); 00044 INLINE int get_repeat_count() const; 00045 00046 INLINE int get_current_task_index() const; 00047 00048 protected: 00049 virtual bool is_runnable(); 00050 virtual DoneStatus do_task(); 00051 virtual void upon_birth(AsyncTaskManager *manager); 00052 virtual void upon_death(AsyncTaskManager *manager, bool clean_exit); 00053 00054 private: 00055 void set_current_task(AsyncTask *task, bool clean_exit); 00056 00057 int _repeat_count; 00058 int _task_index; 00059 PT(AsyncTask) _current_task; 00060 00061 public: 00062 static TypeHandle get_class_type() { 00063 return _type_handle; 00064 } 00065 static void init_type() { 00066 AsyncTask::init_type(); 00067 register_type(_type_handle, "AsyncTaskSequence", 00068 AsyncTask::get_class_type()); 00069 } 00070 virtual TypeHandle get_type() const { 00071 return get_class_type(); 00072 } 00073 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00074 00075 private: 00076 static TypeHandle _type_handle; 00077 }; 00078 00079 #include "asyncTaskSequence.I" 00080 00081 #endif 00082