Panda3D
|
00001 // Filename: asyncTaskCollection.h 00002 // Created by: drose (16Sep08) 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 ASYNCTASKCOLLECTION_H 00016 #define ASYNCTASKCOLLECTION_H 00017 00018 #include "pandabase.h" 00019 #include "pointerToArray.h" 00020 #include "asyncTask.h" 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Class : AsyncTaskCollection 00024 // Description : A list of tasks, for instance as returned by some of 00025 // the AsyncTaskManager query functions. This also 00026 // serves to define an AsyncTaskSequence. 00027 // 00028 // TODO: None of this is thread-safe yet. 00029 //////////////////////////////////////////////////////////////////// 00030 class EXPCL_PANDA_PGRAPH AsyncTaskCollection { 00031 PUBLISHED: 00032 AsyncTaskCollection(); 00033 AsyncTaskCollection(const AsyncTaskCollection ©); 00034 void operator = (const AsyncTaskCollection ©); 00035 INLINE ~AsyncTaskCollection(); 00036 00037 void add_task(AsyncTask *task); 00038 bool remove_task(AsyncTask *task); 00039 void add_tasks_from(const AsyncTaskCollection &other); 00040 void remove_tasks_from(const AsyncTaskCollection &other); 00041 void remove_duplicate_tasks(); 00042 bool has_task(AsyncTask *task) const; 00043 void clear(); 00044 00045 AsyncTask *find_task(const string &name) const; 00046 00047 int get_num_tasks() const; 00048 AsyncTask *get_task(int index) const; 00049 MAKE_SEQ(get_tasks, get_num_tasks, get_task); 00050 void remove_task(int index); 00051 AsyncTask *operator [] (int index) const; 00052 int size() const; 00053 INLINE void operator += (const AsyncTaskCollection &other); 00054 INLINE AsyncTaskCollection operator + (const AsyncTaskCollection &other) const; 00055 00056 void output(ostream &out) const; 00057 void write(ostream &out, int indent_level = 0) const; 00058 00059 private: 00060 typedef PTA(PT(AsyncTask)) AsyncTasks; 00061 AsyncTasks _tasks; 00062 }; 00063 00064 INLINE ostream &operator << (ostream &out, const AsyncTaskCollection &col) { 00065 col.output(out); 00066 return out; 00067 } 00068 00069 #include "asyncTaskCollection.I" 00070 00071 #endif 00072 00073