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
#ifndef _NETWORK_H
#define _NETWORK_H
#include <functional>
#include <vector>
#include <device/Device.hpp>
#include <model/DeviceInfo.hpp>
namespace wa {
class Network {
protected:
std::string networkParams;
std::function<void(Device &)> deviceConnected;
std::function<void(Device &)> deviceDisconnected;
std::vector<Device *> devices;
public:
Network() {}
virtual ~Network() {}
virtual void
setOnDeviceConnected(std::function<void(Device &)> deviceConnected) final {
this->deviceConnected = deviceConnected;
}
virtual void setOnDeviceDisconnected(
std::function<void(Device &)> deviceDisconnected) final {
this->deviceDisconnected = deviceDisconnected;
}
virtual void setNetworkParams(std::string networkParams) {
this->networkParams = networkParams;
}
virtual std::string getNetworkParams() final {
return this->networkParams;
}
//
virtual bool init() = 0;
// returns a human readable user friendly name
virtual std::string getUserFriendlyName() = 0;
// listen
virtual int listen(std::string) = 0;
// connects to the given address
virtual Device *connect(std::string) = 0;
// bind a route to system
virtual int bind(std::string) {
return -1;
}
// unbind a route from system
virtual int unbind(std::string) {
return -1;
}
// discovers different networks
virtual std::vector<DeviceInfo> discover() = 0;
// should be deprecated
std::vector<Device *> getDevices() { return devices; }
};
}; // namespace wa
#endif