1 #include "ActiveBlocksRequest.h"
2 #include "storage/Snapshot.h"
3 #include "storage/SnapshotList.h"
4 #include "GraphDataEngine.h"
7 ActiveBlocksRequest::ActiveBlocksRequest(GraphDataEngine
*data_engine
, const Timestamp
×tamp
)
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 {
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();