Panda3D
asyncTaskCollection.h
1 // Filename: asyncTaskCollection.h
2 // Created by: drose (16Sep08)
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 ASYNCTASKCOLLECTION_H
16 #define ASYNCTASKCOLLECTION_H
17 
18 #include "pandabase.h"
19 #include "pointerToArray.h"
20 #include "asyncTask.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : AsyncTaskCollection
24 // Description : A list of tasks, for instance as returned by some of
25 // the AsyncTaskManager query functions. This also
26 // serves to define an AsyncTaskSequence.
27 //
28 // TODO: None of this is thread-safe yet.
29 ////////////////////////////////////////////////////////////////////
30 class EXPCL_PANDA_PGRAPH AsyncTaskCollection {
31 PUBLISHED:
34  void operator = (const AsyncTaskCollection &copy);
35  INLINE ~AsyncTaskCollection();
36 
37  void add_task(AsyncTask *task);
38  bool remove_task(AsyncTask *task);
39  void add_tasks_from(const AsyncTaskCollection &other);
40  void remove_tasks_from(const AsyncTaskCollection &other);
41  void remove_duplicate_tasks();
42  bool has_task(AsyncTask *task) const;
43  void clear();
44 
45  AsyncTask *find_task(const string &name) const;
46 
47  int get_num_tasks() const;
48  AsyncTask *get_task(int index) const;
49  MAKE_SEQ(get_tasks, get_num_tasks, get_task);
50  void remove_task(int index);
51  AsyncTask *operator [] (int index) const;
52  int size() const;
53  INLINE void operator += (const AsyncTaskCollection &other);
54  INLINE AsyncTaskCollection operator + (const AsyncTaskCollection &other) const;
55 
56  void output(ostream &out) const;
57  void write(ostream &out, int indent_level = 0) const;
58 
59 private:
60  typedef PTA(PT(AsyncTask)) AsyncTasks;
61  AsyncTasks _tasks;
62 };
63 
64 INLINE ostream &operator << (ostream &out, const AsyncTaskCollection &col) {
65  col.output(out);
66  return out;
67 }
68 
69 #include "asyncTaskCollection.I"
70 
71 #endif
72 
73 
A list of tasks, for instance as returned by some of the AsyncTaskManager query functions.
void output(ostream &out) const
Writes a brief one-line description of the AsyncTaskCollection to the indicated output stream...
This class represents a concrete task performed by an AsyncManager.
Definition: asyncTask.h:43