/include/nebu-app-framework/daemonCollection.h

https://github.com/deltaforge/nebu-app-framework-cpp · C Header · 68 lines · 30 code · 10 blank · 28 comment · 0 complexity · aa77181b0470f05c2df82819e27adddc MD5 · raw file

  1. #ifndef NEBUAPPFRAMEWORK_DAEMONCOLLECTION_H_
  2. #define NEBUAPPFRAMEWORK_DAEMONCOLLECTION_H_
  3. #include "nebu-app-framework/daemon.h"
  4. #include <map>
  5. #include <memory>
  6. #include <set>
  7. namespace nebu
  8. {
  9. namespace app
  10. {
  11. namespace framework
  12. {
  13. /** Holds a collection of Daemons in the system for easy retrieval.
  14. * Provides several accessor functions to retrieve a subset of all daemons, e.g., based on their type.
  15. */
  16. class DaemonCollection
  17. {
  18. public:
  19. /** Empty constructor. */
  20. DaemonCollection() { }
  21. /** Virtual destructor provided for inheritance. */
  22. virtual ~DaemonCollection() { }
  23. /** Getter for a set containing all Daemons.
  24. * @return set of Daemon objects.
  25. */
  26. virtual std::set<std::shared_ptr<Daemon>> getDaemons();
  27. /** Getter for the set of Daemons with a filter based on DaemonType.
  28. * @param[in] type the type of Daemon to return.
  29. * @return set of all Daemons of DaemonType type.
  30. */
  31. virtual std::set<std::shared_ptr<Daemon>> getDaemonsForType(DaemonType type);
  32. /** Getter for the set of Daemons with a filter based on DaemonType and launched status.
  33. * @param[in] type the type of Daemon to return.
  34. * @return filtered set of Daemons.
  35. */
  36. virtual std::set<std::shared_ptr<Daemon>> getUnlaunchedDaemonsForType(DaemonType type);
  37. /** Getter for the set of Daemons with a filter based on DaemonType and unlaunched status.
  38. * @param[in] type the type of Daemon to return.
  39. * @return filtered set of Daemons.
  40. */
  41. virtual std::set<std::shared_ptr<Daemon>> getLaunchedDaemonsForType(DaemonType type);
  42. /** Getter for the set of Daemons with a custom filter.
  43. * @param[in] includeInResults a predicate that should be true iff the Daemon should be included
  44. * in the result set of the function.
  45. * @return filtered set of Daemons.
  46. */
  47. virtual std::set<std::shared_ptr<Daemon>> getDaemonsFiltered(bool (*includeInResults)(std::shared_ptr<Daemon>));
  48. /** Adds a Daemon to the collection.
  49. * @param[in] daemon the Daemon to add.
  50. */
  51. virtual void addDaemon(std::shared_ptr<Daemon> daemon);
  52. private:
  53. std::map<int, std::set<std::shared_ptr<Daemon>>> daemons;
  54. };
  55. }
  56. }
  57. }
  58. #endif