forked from truvorskameikin/udp-discovery-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
endpoint.hpp
59 lines (42 loc) · 1.36 KB
/
endpoint.hpp
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
#ifndef __UDP_DISCOVERY_ENDPOINT_H_
#define __UDP_DISCOVERY_ENDPOINT_H_
#include <list>
#include "discovered_endpoint.hpp"
#include "endpoint_parameters.hpp"
namespace udpdiscovery {
namespace impl {
class EndpointEnvInterface {
public:
virtual ~EndpointEnvInterface() {
}
virtual void SetUserData(const std::string& user_data) = 0;
virtual std::list<DiscoveredEndpoint> ListDiscovered() = 0;
virtual void Exit() = 0;
};
class MinimalisticThreadInterface {
public:
virtual ~MinimalisticThreadInterface() {
}
virtual void Detach() = 0;
virtual void Join() = 0;
};
};
class Endpoint {
public:
Endpoint();
~Endpoint();
bool Start(const EndpointParameters& parameters, const std::string& user_data);
void SetUserData(const std::string& user_data);
std::list<DiscoveredEndpoint> ListDiscovered() const;
void Stop(bool wait_for_thread);
private:
Endpoint(const Endpoint&);
Endpoint& operator=(const Endpoint&);
private:
impl::EndpointEnvInterface* env_;
impl::MinimalisticThreadInterface* thread_;
};
bool Same(EndpointParameters::SameEndpointMode mode, const IpPort& lhv, const IpPort& rhv);
bool Same(EndpointParameters::SameEndpointMode mode, const std::list<DiscoveredEndpoint>& lhv, const std::list<DiscoveredEndpoint>& rhv);
};
#endif