Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/util/network_stats_widget.h @ 9385

Last change on this file since 9385 was 9385, checked in by bensch, 19 years ago

orxonox/proxy: better proxy-width approximation

File size: 2.6 KB
Line 
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
16namespace OrxGui
17{
18
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
55      void setClientNameWidths(float width);
56
57
58    protected:
59      virtual void hiding();
60      virtual void showing();
61
62
63    private:
64      HostWidget       _proxyWidget;
65
66      std::vector<HostWidget*>  _clients;
67      float            _clientNameWidth;
68  };
69
70
71
72
73  //! A class to display network Statistics.
74  class NetworkStatsWidget : public GLGuiBox
75  {
76    public:
77      NetworkStatsWidget();
78      virtual ~NetworkStatsWidget();
79
80      void setUpstream(unsigned int upstream);
81      void setDownstream(unsigned int upstream);
82      void setIP(const IP& ip);
83
84
85
86      //void rebuildConnectedHosts(std::vector<hosts> hosts);
87
88      void setMaximum(float max);
89      void setValue(float value);
90
91    protected:
92      virtual void resize();
93      virtual void showing();
94      virtual void hiding();
95
96    private:
97      HostWidget             _thisHost;
98
99      GLGuiText              _upstreamText;
100      GLGuiText              _downstreamText;
101
102      std::vector<HostWidget*>_connectedProxies;
103
104      GLGuiText              _serverIP;
105
106
107      GLGuiText              _valueText;
108      GLGuiBar               _bar;
109  };
110}
111#endif /* _NETWORK_STATS_WIDGET_H */
Note: See TracBrowser for help on using the repository browser.