Fixing problems that aesalon has does nothing but raise more questions . . .
[aesalon.git] / gui / src / session / ActiveBlocksRequest.cpp
blobb0262f603beb66e6d3d485cd05ae4ca889473a8f
1 #include "ActiveBlocksRequest.h"
2 #include "storage/Snapshot.h"
3 #include "storage/SnapshotList.h"
4 #include "GraphDataEngine.h"
5 #include "GraphData.h"
7 ActiveBlocksRequest::ActiveBlocksRequest(GraphDataEngine *data_engine, const Timestamp &timestamp)
8 : DataRequest(data_engine), timestamp(timestamp) {
11 ActiveBlocksRequest::~ActiveBlocksRequest() {
15 void ActiveBlocksRequest::construct_response(SnapshotList *snapshot_list) {
16 Snapshot *snapshot = snapshot_list->get_snapshot_for(timestamp);
17 count = count_blocks(snapshot->get_head_node());
20 void ActiveBlocksRequest::process_response() {
21 get_requester()->add_data(new GraphData(timestamp, qreal(count)));
25 int ActiveBlocksRequest::count_blocks(BiTreeNode *node) const {
26 int count = 0;
27 if(node->get_left()) count += count_blocks(node->get_left());
28 if(node->get_right()) count += count_blocks(node->get_right());
29 count += node->get_block_list_size();
31 return count;