summaryrefslogtreecommitdiff
path: root/sapmanager.h
blob: e9f60cc3f1b73f699765762a3527e77fca910ed4 (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
51
52
53
54
#ifndef SAPMANAGER_H
#define SAPMANAGER_H

#include <QtCore/QObject>
#include <QtCore/QMap>
#include <QtCore/QHash>
#include "sapserviceinfo.h"

class SAPAgent;

class SAPManager : public QObject
{
	Q_OBJECT

	explicit SAPManager(QObject *parent = 0);
	Q_DISABLE_COPY(SAPManager)

public:
	static SAPManager * instance();

	int registerServiceAgent(const SAPServiceInfo &service, SAPAgent *agent);
	void unregisterServiceAgent(int agentId);
	void unregisterServiceAgent(const QString &profile, SAPServiceInfo::Role role);

	int registeredAgentId(const QString &profile, SAPServiceInfo::Role role);

	bool isRegisteredAgent(int agentId) const;
	SAPAgent *agent(int agentId);
	SAPServiceInfo serviceInfo(int agentId) const;

	QSet<QString> allProfiles();

signals:

public slots:

private:
	int findUnusedAgentId() const;
	QHash<QString, int>* profilesByRole(SAPServiceInfo::Role role);

private:
	struct RegisteredAgent {
		int agentId;
		SAPServiceInfo info;
		SAPAgent *agent;
	};

	QMap<int, RegisteredAgent> _agents;

	QHash<QString, int> _consumerProfiles;
	QHash<QString, int> _providerProfiles;
};

#endif // SAPMANAGER_H