[4838] | 1 | /*! |
---|
[9330] | 2 | * @file network_stats_widget.h |
---|
[8972] | 3 | * @brief Definition of an EnergyWidget, that displays a bar and a Text |
---|
[3245] | 4 | */ |
---|
[1853] | 5 | |
---|
[9330] | 6 | #ifndef _NETWORK_STATS_WIDGET_H |
---|
| 7 | #define _NETWORK_STATS_WIDGET_H |
---|
[1853] | 8 | |
---|
[8974] | 9 | #include "glgui_box.h" |
---|
[8972] | 10 | #include "glgui_bar.h" |
---|
| 11 | #include "glgui_text.h" |
---|
[1853] | 12 | |
---|
[9330] | 13 | #include "network/ip.h" |
---|
| 14 | |
---|
| 15 | |
---|
[8972] | 16 | namespace OrxGui |
---|
| 17 | { |
---|
[3543] | 18 | |
---|
[9383] | 19 | class HostWidget : public GLGuiBox |
---|
| 20 | { |
---|
| 21 | public: |
---|
| 22 | HostWidget(const std::string& name, const IP& ip); |
---|
| 23 | ~HostWidget() {}; |
---|
| 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 | GLGuiText _name; //!< The Name of the Proxy server to be displayed. |
---|
| 39 | GLGuiText _ip; //!< The IP of the proxy server. |
---|
| 40 | IP _storedIP; //!< The ip to compare. |
---|
| 41 | }; |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | class ProxyWidget : public GLGuiBox |
---|
| 45 | { |
---|
| 46 | public: |
---|
| 47 | ProxyWidget(const std::string& proxyName, const IP& ip); |
---|
| 48 | |
---|
| 49 | void addClient(const std::string& name, const IP& ip); |
---|
| 50 | |
---|
| 51 | bool removeClient(const IP& ip); |
---|
| 52 | bool removeClient(const std::string& name); |
---|
| 53 | bool removeClient(const std::string& name, const IP& ip); |
---|
| 54 | |
---|
[9385] | 55 | void setClientNameWidths(float width); |
---|
[9383] | 56 | |
---|
[9385] | 57 | |
---|
[9383] | 58 | protected: |
---|
| 59 | virtual void hiding(); |
---|
| 60 | virtual void showing(); |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | private: |
---|
| 64 | HostWidget _proxyWidget; |
---|
| 65 | |
---|
| 66 | std::vector<HostWidget*> _clients; |
---|
[9385] | 67 | float _clientNameWidth; |
---|
[9383] | 68 | }; |
---|
| 69 | |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | |
---|
[9330] | 73 | //! A class to display network Statistics. |
---|
| 74 | class NetworkStatsWidget : public GLGuiBox |
---|
[8972] | 75 | { |
---|
[9383] | 76 | public: |
---|
| 77 | NetworkStatsWidget(); |
---|
| 78 | virtual ~NetworkStatsWidget(); |
---|
[3543] | 79 | |
---|
[9383] | 80 | void setUpstream(unsigned int upstream); |
---|
| 81 | void setDownstream(unsigned int upstream); |
---|
| 82 | void setIP(const IP& ip); |
---|
[2036] | 83 | |
---|
[9330] | 84 | |
---|
[8974] | 85 | |
---|
[9386] | 86 | void addProxy(const std::string& name, const IP& proxy); |
---|
| 87 | |
---|
| 88 | |
---|
[9383] | 89 | //void rebuildConnectedHosts(std::vector<hosts> hosts); |
---|
[9330] | 90 | |
---|
[9383] | 91 | void setMaximum(float max); |
---|
| 92 | void setValue(float value); |
---|
[9330] | 93 | |
---|
[9383] | 94 | protected: |
---|
| 95 | virtual void resize(); |
---|
| 96 | virtual void showing(); |
---|
| 97 | virtual void hiding(); |
---|
[9331] | 98 | |
---|
[9383] | 99 | private: |
---|
[9385] | 100 | HostWidget _thisHost; |
---|
[1853] | 101 | |
---|
[9383] | 102 | GLGuiText _upstreamText; |
---|
| 103 | GLGuiText _downstreamText; |
---|
[1853] | 104 | |
---|
[9385] | 105 | std::vector<HostWidget*>_connectedProxies; |
---|
[9330] | 106 | |
---|
[9383] | 107 | GLGuiText _serverIP; |
---|
[9330] | 108 | |
---|
| 109 | |
---|
[9383] | 110 | GLGuiText _valueText; |
---|
| 111 | GLGuiBar _bar; |
---|
[8972] | 112 | }; |
---|
| 113 | } |
---|
[9330] | 114 | #endif /* _NETWORK_STATS_WIDGET_H */ |
---|