1 | /*! |
---|
2 | * @file network_stats_widget.h |
---|
3 | * @brief Definition of an EnergyWidget, that displays a bar and a Text |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef _NETWORK_STATS_WIDGET_H |
---|
7 | #define _NETWORK_STATS_WIDGET_H |
---|
8 | |
---|
9 | #include "glgui_fixedposition_box.h" |
---|
10 | #include "glgui_bar.h" |
---|
11 | #include "glgui_text.h" |
---|
12 | #include "glgui_pushbutton.h" |
---|
13 | |
---|
14 | #include "network/ip.h" |
---|
15 | |
---|
16 | class NetworkMonitor; |
---|
17 | class NetworkNode; |
---|
18 | |
---|
19 | |
---|
20 | class HostWidget : public OrxGui::GLGuiBox |
---|
21 | { |
---|
22 | public: |
---|
23 | HostWidget(const std::string& name, const IP& ip); |
---|
24 | |
---|
25 | void setName(const std::string& name) { this->_name.setText(name); }; |
---|
26 | void setIP(const IP& ip) { this->_ip.setText(ip.ipString()); this->_storedIP = ip; }; |
---|
27 | |
---|
28 | void setNameWidth(float width) { this->_name.setLineWidth(width); }; |
---|
29 | |
---|
30 | bool operator==(const IP& ip) const { return (this->_storedIP == ip); }; |
---|
31 | bool operator==(const std::string& name) const { return (this->_name == name); }; |
---|
32 | |
---|
33 | protected: |
---|
34 | virtual void showing(); |
---|
35 | virtual void hiding(); |
---|
36 | |
---|
37 | private: |
---|
38 | OrxGui::GLGuiText _name; //!< The Name of the Proxy server to be displayed. |
---|
39 | OrxGui::GLGuiText _ip; //!< The IP of the proxy server. |
---|
40 | IP _storedIP; //!< The ip to compare. |
---|
41 | |
---|
42 | static Font* _font; |
---|
43 | }; |
---|
44 | |
---|
45 | |
---|
46 | class NodeWidget : public OrxGui::GLGuiBox |
---|
47 | { |
---|
48 | public: |
---|
49 | NodeWidget(const std::string& proxyName, const IP& ip); |
---|
50 | NodeWidget(const NetworkNode* node); |
---|
51 | |
---|
52 | void addClient(const NetworkNode* node); |
---|
53 | void addClient(const std::string& name, const IP& ip); |
---|
54 | |
---|
55 | bool removeClient(const IP& ip); |
---|
56 | bool removeClient(const std::string& name); |
---|
57 | bool removeClient(const std::string& name, const IP& ip); |
---|
58 | |
---|
59 | void setClientNameWidths(float width); |
---|
60 | |
---|
61 | |
---|
62 | protected: |
---|
63 | virtual void hiding(); |
---|
64 | virtual void showing(); |
---|
65 | |
---|
66 | |
---|
67 | private: |
---|
68 | HostWidget _proxyWidget; |
---|
69 | |
---|
70 | std::vector<HostWidget*> _clients; |
---|
71 | float _clientNameWidth; |
---|
72 | }; |
---|
73 | |
---|
74 | |
---|
75 | |
---|
76 | |
---|
77 | //! A class to display network Statistics. |
---|
78 | class NetworkStatsWidget : public OrxGui::GLGuiFixedpositionBox |
---|
79 | { |
---|
80 | public: |
---|
81 | static void toggleGUI(); |
---|
82 | |
---|
83 | NetworkStatsWidget(const NetworkMonitor* monitor); |
---|
84 | virtual ~NetworkStatsWidget(); |
---|
85 | |
---|
86 | void setUpstream(unsigned int upstream); |
---|
87 | void setDownstream(unsigned int upstream); |
---|
88 | void setIP(const IP& ip); |
---|
89 | |
---|
90 | |
---|
91 | |
---|
92 | void addProxy(const std::string& name, const IP& proxy); |
---|
93 | void addNode(const NetworkNode* node); |
---|
94 | |
---|
95 | void clearProxies(); |
---|
96 | |
---|
97 | void rebuild(); |
---|
98 | |
---|
99 | //void rebuildConnectedHosts(std::vector<hosts> hosts); |
---|
100 | |
---|
101 | void setMaximum(float max); |
---|
102 | void setValue(float value); |
---|
103 | |
---|
104 | virtual void tick(float dt); |
---|
105 | |
---|
106 | protected: |
---|
107 | virtual void resize(); |
---|
108 | virtual void showing(); |
---|
109 | virtual void hiding(); |
---|
110 | |
---|
111 | private: |
---|
112 | const NetworkMonitor* _monitor; |
---|
113 | |
---|
114 | OrxGui::GLGuiText _thisHostIs; |
---|
115 | HostWidget _thisHost; |
---|
116 | |
---|
117 | OrxGui::GLGuiText _upstreamText; |
---|
118 | OrxGui::GLGuiText _downstreamText; |
---|
119 | |
---|
120 | OrxGui::GLGuiWidget _serverBox; |
---|
121 | |
---|
122 | std::vector<NodeWidget*> _proxies; |
---|
123 | |
---|
124 | |
---|
125 | OrxGui::GLGuiPushButton _refreshButton; |
---|
126 | |
---|
127 | static NetworkStatsWidget* _statsWidget; |
---|
128 | |
---|
129 | //OrxGui::GLGuiText _valueText; |
---|
130 | //OrxGui::GLGuiBar _bar; |
---|
131 | }; |
---|
132 | |
---|
133 | #endif /* _NETWORK_STATS_WIDGET_H */ |
---|