-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlmPublisher.h
More file actions
66 lines (47 loc) · 1.62 KB
/
Copy pathAlmPublisher.h
File metadata and controls
66 lines (47 loc) · 1.62 KB
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
61
62
#ifndef MicroMiddleware_AlmPublisher_h_Included
#define MicroMiddleware_AlmPublisher_h_Included
#include <set>
#include"MicroMiddleware/IncludeExtLibs.h"
#include"MicroMiddleware/Net/RpcBase.h"
#include"MicroMiddleware/NetObjects/InterfaceHandle.h"
#include"MicroMiddleware/NetObjects/GroupHandle.h"
#include"MicroMiddleware/NetObjects/RpcIdentifier.h"
#include"MicroMiddleware/Export.h"
namespace MicroMiddleware
{
// TODO: Having one publisher for each subscriber is a waste for UDP connections!
// -> instead use writeDatagram using hostAddress
// -> Specialize AlmBase to do this!
class DLL_STATE AlmPublisher : public RpcBase, protected Thread
{
public:
AlmPublisher(const InterfaceHandle &interfaceHandle, bool autoStart = true);
virtual ~AlmPublisher()
{}
void StopClient(bool waitForTermination = true);
void StartClient();
bool BindToInterfaceHandle();
bool WaitConnected();
bool WaitForUdpSocket();
virtual void AddTarget(GroupHandle &handle);
virtual void RemoveTarget(GroupHandle &handle);
public:
inline InterfaceHandle GetInterfaceHandle() { return interfaceHandle_; }
inline bool IsRunning() { return isRunning(); }
inline void lock() { clientMutex_.lock(); }
inline void unlock() { clientMutex_.unlock(); }
protected:
virtual void run();
private:
bool bindToInterfaceHandle();
void initUdpSocket();
protected:
bool runThread_;
InterfaceHandle interfaceHandle_;
mutable Mutex clientMutex_;
UdpSocket::Ptr udpSocket_;
RpcIdentifier rpcAddTarget_;
RpcIdentifier rpcRemoveTarget_;
};
}; // namespace MicroMiddleware
#endif // MicroMiddleware_AlmPublisher_h_Included