-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.cpp
More file actions
44 lines (36 loc) · 1.19 KB
/
graph.cpp
File metadata and controls
44 lines (36 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "graph.hpp"
#include "widgets.hpp"
#include <exception>
#include <memory>
nDPIsrvd_graph::nDPIsrvd_graph() : m_recvq(), m_imweb() {}
void nDPIsrvd_graph::init(int width, int height) {
m_imweb.init(width, height);
m_imweb.addDrawable(std::make_shared<EventPieChart>());
m_imweb.addDrawable(std::make_shared<FlowEventPlotter>());
}
void nDPIsrvd_graph::loop() {
m_imweb.loop([&]() {
bool retval = true;
if (!m_recvq.empty()) {
auto nj = m_recvq.pop();
#if 0
printf("Thread: %d - Event: %d - Subevent: %d - Alias: %s - Source: %s - "
"Packet %llu\n",
nj.thread_id, nj.event, nj.subevent_id, nj.alias.c_str(),
nj.source.c_str(), nj.packet_id);
#endif
auto drawablesBegin = m_imweb.drawablesBegin();
auto drawablesEnd = m_imweb.drawablesEnd();
for (auto &drawablePtr = drawablesBegin; drawablePtr != drawablesEnd;
++drawablePtr) {
auto drawable = *drawablePtr;
auto widget = reinterpret_pointer_cast<Widget>(drawable);
if (widget)
widget->update(m_stats);
else
throw std::runtime_error("Invalid cast to class Widget!");
}
}
return retval;
});
}