-
Notifications
You must be signed in to change notification settings - Fork 4
/
ManagerApi.h
executable file
·56 lines (38 loc) · 1.3 KB
/
ManagerApi.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
#ifndef _MANAGERAPI_H_
#define _MANAGERAPI_H_
#include <boost/thread.hpp>
#include <vector>
#include "Synchronizer.h"
struct ErrorCode;
class CManagerInterface;
class CManagerFactory;
class ManagerApi {
public:
static ManagerApi &Instance();
// for performance and low memory footprint
void RequestChart(int login, const char *symbol, int period, std::string &mode_str, __time32_t start, __time32_t end,
__time32_t *timestamp, std::string &json_str);
private:
bool IsValid();
inline void Stop() {
InterlockedExchange(&m_running, 0);
}
CManagerInterface *GetInterface();
void PutInterface(CManagerInterface *manager);
void Initialize(CManagerInterface *in);
void StartHeartBeat();
ManagerApi();
~ManagerApi();
ManagerApi(ManagerApi const &) = delete;
void operator=(ManagerApi const &) = delete;
void ErrorCodeToString(const ErrorCode *ec, std::string &str);
private:
CManagerFactory *m_factory;
std::vector<CManagerInterface *> m_available_managers;
std::vector<CManagerInterface *> m_managers;
volatile long m_running;
Synchronizer m_synchronizer;
boost::thread m_thread;
static const int MAX_MANAGER_LOGIN = 32;
};
#endif // !_MANAGERAPI_H_