Debian Codegraph @

yo/concrete/examples/monitor/monitor.h

raw
1 #include <string>
2 #include <map>
3
4 #include <memory>
5
6 #include "../selector.h"
7 #include "child.h"
8
9 //CLASS
10 class Monitor
11 {
12 enum Commands
13 {
14 UNKNOWN,
15 START,
16 EXIT,
17 STOP,
18 TEXT,
19 sizeofCommands
20 };
21
22 using MapIntChild = std::map<int, std::shared_ptr<Child>>;
23
24 friend class Find;
25 class Find
26 {
27 int d_nr;
28 public:
29 Find(int nr);
30 bool operator()(MapIntChild::value_type &vt) const;
31 };
32
33 Selector d_selector;
34 int d_nr;
35 MapIntChild d_child;
36
37 static void (Monitor::*s_handler[])(int, std::string const &);
38 static int s_initialize;
39
40 public:
41 enum Done
42 {};
43
44 Monitor();
45 void run();
46
47 private:
48 static void killChild(MapIntChild::value_type it);
49 static int initialize();
50
51 Commands next(int *value, std::string *line);
52 void processInput();
53 void processChild(int fd);
54
55 void createNewChild(int, std::string const &);
56 void exiting(int = 0, std::string const &msg = std::string{});
57 void sendChild(int value, std::string const &line);
58 void stopChild(int value, std::string const &);
59 void unknown(int, std::string const &);
60 };
61 //=
62
63 //CONS
64 inline Monitor::Monitor()
65 :
66 d_nr(0)
67 {}
68 //=
69
70 //FINDIMP
71 inline Monitor::Find::Find(int nr)
72 :
73 d_nr(nr)
74 {}
75 inline bool Monitor::Find::operator()(MapIntChild::value_type &vt) const
76 {
77 return d_nr == vt.second->nr();
78 }
79 //=