return memcmp(&sin6.sin6_addr.s6_addr, &rhs.sin6.sin6_addr.s6_addr, 16) > 0;
}
- struct addressOnlyLessThan: public std::binary_function<string, string, bool>
+ struct addressOnlyLessThan: public std::binary_function<ComboAddress, ComboAddress, bool>
{
bool operator()(const ComboAddress& a, const ComboAddress& b) const
{
void StatBag::declareComboRing(const string &name, const string &help, unsigned int size)
{
- d_comborings[name]=StatRing<ComboAddress, ComboAddress::addressOnlyLessThan >(size);
+ d_comborings[name]=StatRing<SComboAddress>(size);
d_comborings[name].setHelp(help);
}
if(d_rings.count(name))
return d_rings[name].get();
else {
- typedef pair<ComboAddress, unsigned int> stor_t;
+ typedef pair<SComboAddress, unsigned int> stor_t;
vector<stor_t> raw =d_comborings[name].get();
vector<pair<string, unsigned int> > ret;
BOOST_FOREACH(const stor_t& stor, raw) {
- ret.push_back(make_pair(stor.first.toString(), stor.second));
+ ret.push_back(make_pair(stor.first.ca.toString(), stor.second));
}
return ret;
}
vector<string> ret;
for(map<string,StatRing<string> >::const_iterator i=d_rings.begin();i!=d_rings.end();++i)
ret.push_back(i->first);
- for(map<string,StatRing<ComboAddress, ComboAddress::addressOnlyLessThan> >::const_iterator i=d_comborings.begin();i!=d_comborings.end();++i)
+ for(map<string,StatRing<SComboAddress> >::const_iterator i=d_comborings.begin();i!=d_comborings.end();++i)
ret.push_back(i->first);
return ret;
}
template class StatRing<std::string>;
-template class StatRing<ComboAddress, ComboAddress::addressOnlyLessThan >;
+template class StatRing<SComboAddress>;
#include "iputils.hh"
#include <boost/circular_buffer.hpp>
+struct SComboAddress
+{
+ SComboAddress(const ComboAddress& orig) : ca(orig) {}
+ ComboAddress ca;
+ bool operator<(const SComboAddress& rhs) const
+ {
+ return ComboAddress::addressOnlyLessThan()(ca, rhs.ca);
+ }
+};
+
+
template<typename T, typename Comp=std::less<T> >
class StatRing
{
map<string, AtomicCounter *> d_stats;
map<string, string> d_keyDescrips;
map<string,StatRing<string> >d_rings;
- map<string,StatRing<ComboAddress, ComboAddress::addressOnlyLessThan> >d_comborings;
+ map<string,StatRing<SComboAddress> >d_comborings;
typedef boost::function<uint64_t(const std::string&)> func_t;
typedef map<string, func_t> funcstats_t;
funcstats_t d_funcstats;