-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMembershipManagerConnection.h
75 lines (56 loc) · 1.87 KB
/
MembershipManagerConnection.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
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef MembershipManager_MembershipManagerConnection_h_IsIncluded
#define MembershipManager_MembershipManagerConnection_h_IsIncluded
#include "MembershipManager/IncludeExtLibs.h"
using namespace std;
// --------------------------------------------------------
// struct MembershipManagerConnectionConfig
// --------------------------------------------------------
struct MembershipManagerConnectionConfig
{
static int membershipManagerPort;
};
// --------------------------------------------------------
// class MembershipManagerConnection
// --------------------------------------------------------
/**
* Class MembershipManagerConnection logs in the component.
*/
class MembershipManagerConnection : protected Thread
{
public:
MembershipManagerConnection(const HostInformation &info, InterfaceHandle handle, bool autorStart = false);
virtual ~MembershipManagerConnection();
bool Login();
void Logout();
bool IsLoggedIn();
bool StopConnection(bool wait = true);
bool StartConnection(bool wait = false);
void WaitForTermination() { Thread::wait(); }
private:
virtual void run();
bool login();
void logout();
private:
inline bool runThread() { MutexLocker lock(&classMutex_); return runThread_; }
inline bool automaticLogin() { MutexLocker lock(&classMutex_); return automaticLogin_; }
inline void lock() { classMutex_.lock(); }
inline void unlock() { classMutex_.unlock(); }
inline void wakeAll() { classCondition_.wakeAll(); }
inline bool lockedAndUnlockedWait(int64 ms)
{
lock();
bool wokenUp = classCondition_.wait(&classMutex_, ms);
unlock();
return wokenUp;
}
private:
bool runThread_;
bool isLoggedIn_;
bool automaticLogin_;
MembershipManagerClient *membershipManagerProxy_;
HostInformation myHostInformation_;
InterfaceHandle membershipManagerHandle_;
Mutex classMutex_;
WaitCondition classCondition_;
};
#endif