]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/configuration/sgconfig-ng/main_thread.h
Merge branch 'naffanya-dev'
[stg.git] / projects / stargazer / plugins / configuration / sgconfig-ng / main_thread.h
1 #ifndef __MAIN_THREAD_H__
2 #define __MAIN_THREAD_H__
3
4 #include <list>
5
6 #include "os_int.h"
7
8 class CONFIG_THREAD;
9 class ADMINS;
10 class TARIFFS;
11 class USERS;
12 class SETTINGS;
13
14 class MAIN_THREAD {
15 public:
16     MAIN_THREAD(ADMINS * a, TARIFFS * t, USERS * u, const SETTINGS * s);
17     ~MAIN_THREAD();
18
19     void operator() ();
20
21     void Stop() { running = false; };
22     void SetPort(uint16_t p) { port = p; };
23     void SetClasses(ADMINS * a,
24                     TARIFFS * t,
25                     USERS * u,
26                     const SETTINGS * s)
27     {
28         admins = a;
29         tariffs = t;
30         users = u;
31         settings = s;
32     };
33
34     void SetMaxConnections(unsigned max) { maxConnections = max; };
35
36 private:
37     bool running;
38     int sd;
39     uint16_t port;
40     unsigned maxConnections;
41
42     ADMINS * admins;
43     TARIFFS * tariffs;
44     USERS * users;
45     const SETTINGS * settings;
46
47     std::list<CONFIG_THREAD> connections;
48
49     bool InitNetwork();
50     bool WaitConnection();
51     void AcceptConnection();
52     void CleanupThreads();
53
54 };
55
56 #endif