Changeset 9383 in orxonox.OLD for branches/proxy/src/util
- Timestamp:
- Jul 21, 2006, 12:51:19 PM (18 years ago)
- Location:
- branches/proxy/src/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/util/network_stats_widget.cc
r9369 r9383 22 22 namespace OrxGui 23 23 { 24 HostWidget::HostWidget(const std::string& name, const IP& ip) 25 : GLGuiBox(Horizontal) 26 { 27 this->setName(name); 28 this->setIP(ip); 29 30 this->pack(&this->_name); 31 this->pack(&this->_ip); 32 } 33 34 void HostWidget::showing() 35 { 36 this->_name.show(); 37 this->_ip.show(); 38 } 39 40 void HostWidget::hiding() 41 { 42 this->_name.hide(); 43 this->_ip.hide(); 44 } 45 46 47 48 //======================================================// 49 50 51 ProxyWidget::ProxyWidget(const std::string& proxyName, const IP& ip) 52 : _proxyWidget(proxyName, ip) 53 { 54 this->pack(&_proxyWidget); 55 } 56 57 void ProxyWidget::addClient(const std::string& name, const IP& ip) 58 { 59 HostWidget* newClient = new HostWidget(name, ip); 60 61 this->pack(newClient); 62 63 if (this->isVisible()) 64 newClient->show(); 65 } 66 67 bool ProxyWidget::removeClient(const IP& ip) 68 { 69 std::vector<HostWidget*>::iterator rmIt; 70 for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt) 71 { 72 if (*(*rmIt) == ip) 73 { 74 delete (*rmIt); 75 this->_clients.erase(rmIt); 76 return true; 77 } 78 } 79 return false; 80 } 81 82 bool ProxyWidget::removeClient(const std::string& name) 83 { 84 std::vector<HostWidget*>::iterator rmIt; 85 for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt) 86 { 87 if (*(*rmIt) == name) 88 { 89 delete (*rmIt); 90 this->_clients.erase(rmIt); 91 return true; 92 } 93 } 94 return false; 95 96 } 97 98 bool ProxyWidget::removeClient(const std::string& name, const IP& ip) 99 { 100 std::vector<HostWidget*>::iterator rmIt; 101 for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt) 102 { 103 if (*(*rmIt) == ip && *(*rmIt) == name) 104 { 105 delete (*rmIt); 106 this->_clients.erase(rmIt); 107 return true; 108 } 109 } 110 return false; 111 } 112 113 114 void ProxyWidget::hiding() 115 { 116 this->_proxyWidget.hide(); 117 for (unsigned int i = 0; i < this->_clients.size(); ++i) 118 this->_clients[i]->hide(); 119 } 120 121 void ProxyWidget::showing() 122 { 123 this->_proxyWidget.show(); 124 for (unsigned int i = 0; i < this->_clients.size(); ++i) 125 this->_clients[i]->show(); 126 } 127 128 129 //======================================================// 130 131 132 24 133 /** 25 134 * @brief standard constructor 26 135 */ 27 136 NetworkStatsWidget::NetworkStatsWidget () 137 : GLGuiBox(Vertical) 28 138 { 29 139 // this->setClassID(CL_PROTO_ID, "NetworkStatsWidget"); … … 52 162 */ 53 163 NetworkStatsWidget::~NetworkStatsWidget () 54 { 55 } 164 {} 56 165 57 166 -
branches/proxy/src/util/network_stats_widget.h
r9347 r9383 17 17 { 18 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 56 protected: 57 virtual void hiding(); 58 virtual void showing(); 59 60 61 private: 62 HostWidget _proxyWidget; 63 64 std::vector<HostWidget*> _clients; 65 }; 66 67 68 69 19 70 //! A class to display network Statistics. 20 71 class NetworkStatsWidget : public GLGuiBox 21 72 { 73 public: 74 NetworkStatsWidget(); 75 virtual ~NetworkStatsWidget(); 22 76 23 public: 24 NetworkStatsWidget(); 25 virtual ~NetworkStatsWidget(); 26 27 void setUpstream(unsigned int upstream); 28 void setDownstream(unsigned int upstream); 29 void setIP(const IP& ip); 77 void setUpstream(unsigned int upstream); 78 void setDownstream(unsigned int upstream); 79 void setIP(const IP& ip); 30 80 31 81 32 82 33 //void rebuildConnectedHosts(std::vector<hosts> hosts);83 //void rebuildConnectedHosts(std::vector<hosts> hosts); 34 84 35 void setMaximum(float max);36 void setValue(float value);85 void setMaximum(float max); 86 void setValue(float value); 37 87 38 protected:39 virtual void resize();40 virtual void showing();41 virtual void hiding();88 protected: 89 virtual void resize(); 90 virtual void showing(); 91 virtual void hiding(); 42 92 43 private:44 IP _ip;45 GLGuiText _ipText;93 private: 94 IP _ip; 95 GLGuiText _ipText; 46 96 47 GLGuiText _upstreamText;48 GLGuiText _downstreamText;97 GLGuiText _upstreamText; 98 GLGuiText _downstreamText; 49 99 50 std::vector<GLGuiText> _connectedHosts;100 std::vector<GLGuiText> _connectedHosts; 51 101 52 GLGuiText _serverIP;102 GLGuiText _serverIP; 53 103 54 104 55 GLGuiText _valueText;56 GLGuiBar _bar;105 GLGuiText _valueText; 106 GLGuiBar _bar; 57 107 }; 58 108 }
Note: See TracChangeset
for help on using the changeset viewer.