/* */ #include "ServerStatMan.h" #include "ServerStat.h" #include #include #include namespace aria2 { ServerStatMan::ServerStatMan() {} ServerStatMan::~ServerStatMan() {} SharedHandle ServerStatMan::find(const std::string& hostname, const std::string& protocol) const { SharedHandle ss(new ServerStat(hostname, protocol)); std::deque >::const_iterator i = std::lower_bound(_serverStats.begin(), _serverStats.end(), ss); if(i != _serverStats.end() && (*i)->getHostname() == hostname && (*i)->getProtocol() == protocol) { return *i; } else { return SharedHandle(); } } bool ServerStatMan::add(const SharedHandle& serverStat) { std::deque >::iterator i = std::lower_bound(_serverStats.begin(), _serverStats.end(), serverStat); if(i != _serverStats.end() && (*i) == serverStat) { return false; } else { _serverStats.insert(i, serverStat); return true; } } void ServerStatMan::save(std::ostream& out) const { std::copy(_serverStats.begin(), _serverStats.end(), std::ostream_iterator >(out, "\n")); } } // namespace aria2