-
Notifications
You must be signed in to change notification settings - Fork 0
/
connectionmanager.h
60 lines (43 loc) · 1.35 KB
/
connectionmanager.h
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
55
56
57
58
59
60
#ifndef CONNECTIONMANAGER_H
#define CONNECTIONMANAGER_H
#include "remotedev_global.h"
#include "connection.h"
#include <QMutex>
#include <QSharedPointer>
#include <QHash>
namespace Core { class Id; }
namespace ProjectExplorer { class IDevice; }
namespace RemoteDev {
namespace Internal {
class RemoteDevPlugin;
class ConnectionManager : public QObject
{
Q_OBJECT
public:
static ConnectionManager *instance();
/**
* @brief connectionForDevice - create/get connection to host by device
* The function tries to look up a connection in the connection pool,
* if none found, creates new by a configuration
* @param device Host device for lookup
* @return a connection instance
*/
static Connection::Ptr connectionForDevice(const ProjectExplorer::IDevice &device);
signals:
void disconnected(Connection::Ptr connection);
void connectionError(Connection::Ptr connection);
private:
explicit ConnectionManager(QObject *parent = 0);
virtual ~ConnectionManager();
private slots:
void onDisconnected();
void onConnectionError();
private:
static ConnectionManager *m_instance;
QHash<Core::Id, Connection::Ptr> m_connectionPool;
QMutex m_connectionPoolMutex;
friend class RemoteDev::Internal::RemoteDevPlugin;
};
} // namespace Internal
} // namespace RemoteDev
#endif // CONNECTIONMANAGER_H