Panda3D

Loading...
Searching...
No Matches
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 {
28PUBLISHED:
29 AsyncTaskCollection();
30 AsyncTaskCollection(const AsyncTaskCollection &copy);
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
61INLINE 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
asyncTaskCollection.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
asyncTask.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
AsyncTaskCollection
A list of tasks, for instance as returned by some of the AsyncTaskManager query functions.
Definition asyncTaskCollection.h:27
AsyncTaskCollection::write
void write(std::ostream &out, int indent_level=0) const
Writes a complete multi-line description of the AsyncTaskCollection to the indicated output stream.
Definition asyncTaskCollection.cxx:262
AsyncTaskCollection::has_task
bool has_task(AsyncTask *task) const
Returns true if the indicated AsyncTask appears in this collection, false otherwise.
Definition asyncTaskCollection.cxx:155
AsyncTaskCollection::output
void output(std::ostream &out) const
Writes a brief one-line description of the AsyncTaskCollection to the indicated output stream.
Definition asyncTaskCollection.cxx:249
AsyncTaskCollection::get_num_tasks
get_num_tasks
Returns the number of AsyncTasks in the collection.
Definition asyncTaskCollection.h:46
AsyncTaskCollection::add_task
void add_task(AsyncTask *task)
Adds a new AsyncTask to the collection.
Definition asyncTaskCollection.cxx:45
AsyncTaskCollection::size
size_t size() const
Returns the number of tasks in the collection.
Definition asyncTaskCollection.cxx:240
AsyncTaskCollection::get_task
get_task
Returns the nth AsyncTask in the collection.
Definition asyncTaskCollection.h:46
AsyncTaskCollection::add_tasks_from
void add_tasks_from(const AsyncTaskCollection &other)
Adds all the AsyncTasks indicated in the other collection to this task.
Definition asyncTaskCollection.cxx:99
AsyncTaskCollection::clear
void clear()
Removes all AsyncTasks from the collection.
Definition asyncTaskCollection.cxx:168
AsyncTaskCollection::find_task
AsyncTask * find_task(const std::string &name) const
Returns the task in the collection with the indicated name, if any, or NULL if no task has that name.
Definition asyncTaskCollection.cxx:177
AsyncTaskCollection::remove_duplicate_tasks
void remove_duplicate_tasks()
Removes any duplicate entries of the same AsyncTasks on this collection.
Definition asyncTaskCollection.cxx:130
AsyncTaskCollection::remove_tasks_from
void remove_tasks_from(const AsyncTaskCollection &other)
Removes from this collection all of the AsyncTasks listed in the other collection.
Definition asyncTaskCollection.cxx:112
AsyncTaskCollection::remove_task
bool remove_task(AsyncTask *task)
Removes the indicated AsyncTask from the collection.
Definition asyncTaskCollection.cxx:65
AsyncTask
This class represents a concrete task performed by an AsyncManager.
Definition asyncTask.h:32
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerToArray.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.