PageRenderTime 21ms CodeModel.GetById 14ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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