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_box.h" |
---|
10 | #include "glgui_bar.h" |
---|
11 | #include "glgui_text.h" |
---|
12 | |
---|
13 | #include "network/ip.h" |
---|
14 | |
---|
15 | |
---|
16 | |
---|
17 | class HostWidget : public OrxGui::GLGuiBox |
---|
18 | { |
---|
19 | public: |
---|
20 | HostWidget(const std::string& name, const IP& ip); |
---|
21 | ~HostWidget() {}; |
---|
22 | |
---|
23 | void setName(const std::string& name) { this->_name.setText(name); }; |
---|
24 | void setIP(const IP& ip) { this->_ip.setText(ip.ipString()); this->_storedIP = ip; }; |
---|
25 | |
---|
26 | void setNameWidth(float width) { this->_name.setLineWidth(width); }; |
---|
27 | |
---|
28 | bool operator==(const IP& ip) const { return (this->_storedIP == ip); }; |
---|
29 | bool operator==(const std::string& name) const { return (this->_name == name); }; |
---|
30 | |
---|
31 | protected: |
---|
32 | virtual void showing(); |
---|
33 | virtual void hiding(); |
---|
34 | |
---|
35 | private: |
---|
36 | OrxGui::GLGuiText _name; //!< The Name of the Proxy server to be displayed. |
---|
37 | OrxGui::GLGuiText _ip; //!< The IP of the proxy server. |
---|
38 | IP _storedIP; //!< The ip to compare. |
---|
39 | }; |
---|
40 | |
---|
41 | |
---|
42 | class ProxyWidget : public OrxGui::GLGuiBox |
---|
43 | { |
---|
44 | public: |
---|
45 | ProxyWidget(const std::string& proxyName, const IP& ip); |
---|
46 | |
---|
47 | void addClient(const std::string& name, const IP& ip); |
---|
48 | |
---|
49 | bool removeClient(const IP& ip); |
---|
50 | bool removeClient(const std::string& name); |
---|
51 | bool removeClient(const std::string& name, const IP& ip); |
---|
52 | |
---|
53 | void setClientNameWidths(float width); |
---|
54 | |
---|
55 | |
---|
56 | protected: |
---|
57 | virtual void hiding(); |
---|
58 | virtual void showing(); |
---|
59 | |
---|
60 | |
---|
61 | private: |
---|
62 | HostWidget _proxyWidget; |
---|
63 | |
---|
64 | std::vector<HostWidget*> _clients; |
---|
65 | float _clientNameWidth; |
---|
66 | }; |
---|
67 | |
---|
68 | |
---|
69 | |
---|
70 | |
---|
71 | //! A class to display network Statistics. |
---|
72 | class NetworkStatsWidget : public OrxGui::GLGuiBox |
---|
73 | { |
---|
74 | public: |
---|
75 | void gui(); |
---|
76 | |
---|
77 | public: |
---|
78 | NetworkStatsWidget(); |
---|
79 | virtual ~NetworkStatsWidget(); |
---|
80 | |
---|
81 | void setUpstream(unsigned int upstream); |
---|
82 | void setDownstream(unsigned int upstream); |
---|
83 | void setIP(const IP& ip); |
---|
84 | |
---|
85 | |
---|
86 | |
---|
87 | void addProxy(const std::string& name, const IP& proxy); |
---|
88 | |
---|
89 | |
---|
90 | //void rebuildConnectedHosts(std::vector<hosts> hosts); |
---|
91 | |
---|
92 | void setMaximum(float max); |
---|
93 | void setValue(float value); |
---|
94 | |
---|
95 | protected: |
---|
96 | virtual void resize(); |
---|
97 | virtual void showing(); |
---|
98 | virtual void hiding(); |
---|
99 | |
---|
100 | private: |
---|
101 | HostWidget _thisHost; |
---|
102 | |
---|
103 | OrxGui::GLGuiText _upstreamText; |
---|
104 | OrxGui::GLGuiText _downstreamText; |
---|
105 | |
---|
106 | std::vector<HostWidget*>_connectedProxies; |
---|
107 | |
---|
108 | OrxGui::GLGuiText _serverIP; |
---|
109 | |
---|
110 | |
---|
111 | OrxGui::GLGuiText _valueText; |
---|
112 | OrxGui::GLGuiBar _bar; |
---|
113 | }; |
---|
114 | |
---|
115 | #endif /* _NETWORK_STATS_WIDGET_H */ |
---|