summaryrefslogtreecommitdiff
path: root/libsowatch/registry.h
blob: ca7252ae47622f909104c432689309396c6ffb25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef SOWATCH_REGISTRY_H
#define SOWATCH_REGISTRY_H

#include <QtCore/QString>
#include <QtCore/QMap>
#include "sowatch_global.h"

namespace sowatch
{

class WatchPluginInterface;
class NotificationPluginInterface;
class WatchletPluginInterface;

class SOWATCH_EXPORT Registry
{
public:
	static Registry* registry();

	inline WatchPluginInterface* getWatchPlugin(const QString& id) {
		return _drivers.value(id, 0);
	}

	inline NotificationPluginInterface* getNotificationPlugin(const QString& id) {
		return _providers.value(id, 0);
	}

	inline WatchletPluginInterface* getWatchletPlugin(const QString& id) {
		return _watchlets.value(id, 0);
	}

protected:
	Registry();
	~Registry();

private:
	static Registry* singleRegistry;

	QMap<QString, WatchPluginInterface*> _drivers;
	QMap<QString, NotificationPluginInterface*> _providers;
	QMap<QString, WatchletPluginInterface*> _watchlets;

	void loadDrivers();
	void loadNotificationProviders();
	void loadWatchlets();
};

}

#endif // SOWATCH_REGISTRY_H