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