asyncTaskCollection.h 2.2 KB

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