Panda3D
asyncTaskCollection.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 asyncTaskCollection.h
10  * @author drose
11  * @date 2008-09-16
12  */
13 
14 #ifndef ASYNCTASKCOLLECTION_H
15 #define ASYNCTASKCOLLECTION_H
16 
17 #include "pandabase.h"
18 #include "pointerToArray.h"
19 #include "asyncTask.h"
20 
21 /**
22  * A list of tasks, for instance as returned by some of the AsyncTaskManager
23  * query functions. This also serves to define an AsyncTaskSequence.
24  *
25  * TODO: None of this is thread-safe yet.
26  */
27 class EXPCL_PANDA_EVENT AsyncTaskCollection {
28 PUBLISHED:
31  void operator = (const AsyncTaskCollection &copy);
32  INLINE ~AsyncTaskCollection();
33 
34  void add_task(AsyncTask *task);
35  bool remove_task(AsyncTask *task);
36  void add_tasks_from(const AsyncTaskCollection &other);
37  void remove_tasks_from(const AsyncTaskCollection &other);
38  void remove_duplicate_tasks();
39  bool has_task(AsyncTask *task) const;
40  void clear();
41 
42  AsyncTask *find_task(const std::string &name) const;
43 
44  size_t get_num_tasks() const;
45  AsyncTask *get_task(size_t index) const;
46  MAKE_SEQ(get_tasks, get_num_tasks, get_task);
47  void remove_task(size_t index);
48  AsyncTask *operator [] (size_t index) const;
49  size_t size() const;
50  INLINE void operator += (const AsyncTaskCollection &other);
51  INLINE AsyncTaskCollection operator + (const AsyncTaskCollection &other) const;
52 
53  void output(std::ostream &out) const;
54  void write(std::ostream &out, int indent_level = 0) const;
55 
56 private:
57  typedef PTA(PT(AsyncTask)) AsyncTasks;
58  AsyncTasks _tasks;
59 };
60 
61 INLINE std::ostream &operator << (std::ostream &out, const AsyncTaskCollection &col) {
62  col.output(out);
63  return out;
64 }
65 
66 #include "asyncTaskCollection.I"
67 
68 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A list of tasks, for instance as returned by some of the AsyncTaskManager query functions.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void output(std::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:32
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.