Add session_stats_alert to python bindings

This commit is contained in:
Andrew Resch 2016-01-13 17:30:51 -08:00
parent 6552138ae5
commit 2e90ea7493
1 changed files with 19 additions and 0 deletions

View File

@ -6,6 +6,8 @@
#include <libtorrent/alert.hpp>
#include <libtorrent/alert_types.hpp>
#include <libtorrent/piece_picker.hpp> // for piece_block
#include <libtorrent/performance_counters.hpp>
#include <libtorrent/session_stats.hpp>
#include <memory>
using namespace boost::python;
@ -179,6 +181,19 @@ dict dht_put_item(dht_put_alert const& alert)
return d;
}
dict session_stats_values(session_stats_alert const& alert)
{
std::vector<stats_metric> map = session_stats_metrics();
dict d;
for (std::vector<stats_metric>::const_iterator i = map.begin();
i != map.end(); ++i)
{
d[i->name] = alert.values[i->value_index];
}
return d;
}
void bind_alert()
{
using boost::noncopyable;
@ -725,4 +740,8 @@ void bind_alert()
"dht_put_alert", no_init)
.add_property("item", &dht_put_item)
;
class_<session_stats_alert, bases<alert>, noncopyable>(
"session_stats_alert", no_init)
.add_property("values", &session_stats_values)
;
}