From 328b7674353ee8bda0b1bb20fbe182bdec54f5ab Mon Sep 17 00:00:00 2001 From: strange Date: Thu, 11 Feb 2010 21:32:43 -0700 Subject: [PATCH] An eureka moment that should never have had to happen . . . As far as the data views go, rather than implementing a whole group of visualizations, I think I'll just go with two major ones: a table and a graph. The graph can be configured (two, three axis), with a number of data sources, the control of which is always time. The y-axis can be configured as required. The table is simply a table which can acquire data from a number of sources, such as the blocks, the references, etc. Any number of table/graph tabs can be spawned off, to provide a nice way of displaying the information across multiple screens. The primary difference (besides the obvious display differences . . .) is how each receives information: graphs act upon a range of pre-calculated data that is abstracted somewhat from the actual data (or, in a less confusing manner, calculated statistics from given data), whereas tables etc. act upon the actual gathered data itself. However, that's for the future . . . the tree needs to be implemented first. --- gui/src/session/DataView.cpp | 1 + gui/src/session/DataView.h | 6 ++++++ gui/src/session/Graph.cpp | 10 +++++++++ gui/src/session/Graph.h | 12 +++++++++++ gui/src/session/Session.cpp | 1 + gui/src/storage/AllocEvent.cpp | 46 +++++++++++------------------------------- gui/src/storage/BiTreeNode.cpp | 11 ++++++++-- gui/src/storage/BiTreeNode.h | 2 +- 8 files changed, 52 insertions(+), 37 deletions(-) create mode 100644 gui/src/session/DataView.cpp create mode 100644 gui/src/session/DataView.h create mode 100644 gui/src/session/Graph.cpp create mode 100644 gui/src/session/Graph.h diff --git a/gui/src/session/DataView.cpp b/gui/src/session/DataView.cpp new file mode 100644 index 0000000..9954c53 --- /dev/null +++ b/gui/src/session/DataView.cpp @@ -0,0 +1 @@ +#include "DataView.h" diff --git a/gui/src/session/DataView.h b/gui/src/session/DataView.h new file mode 100644 index 0000000..745f355 --- /dev/null +++ b/gui/src/session/DataView.h @@ -0,0 +1,6 @@ +#ifndef AESALON_GUI_SESSION_DATA_VIEW_H +#define AESALON_GUI_SESSION_DATA_VIEW_H + + + +#endif diff --git a/gui/src/session/Graph.cpp b/gui/src/session/Graph.cpp new file mode 100644 index 0000000..a8ed751 --- /dev/null +++ b/gui/src/session/Graph.cpp @@ -0,0 +1,10 @@ +#include "Graph.h" +#include "Graph.moc" + +Graph::Graph(QWidget *parent) : QWidget(parent) { + +} + +Graph::~Graph() { + +} diff --git a/gui/src/session/Graph.h b/gui/src/session/Graph.h new file mode 100644 index 0000000..bf0e89c --- /dev/null +++ b/gui/src/session/Graph.h @@ -0,0 +1,12 @@ +#ifndef AESALON_GUI_SESSION_GRAPH_H +#define AESALON_GUI_SESSION_GRAPH_H + +#include + +class Graph : public QWidget { Q_OBJECT +public: + Graph(QWidget *parent); + virtual ~Graph(); +}; + +#endif diff --git a/gui/src/session/Session.cpp b/gui/src/session/Session.cpp index 1038df0..99f2f6a 100644 --- a/gui/src/session/Session.cpp +++ b/gui/src/session/Session.cpp @@ -10,6 +10,7 @@ Session::Session(QWidget *parent, DataSource *data_source) : QWidget(parent), da Session::~Session() { data_receiver->quit(); + data_receiver->wait(); } void Session::handle_event(Event *event) { diff --git a/gui/src/storage/AllocEvent.cpp b/gui/src/storage/AllocEvent.cpp index cb54926..f68332d 100644 --- a/gui/src/storage/AllocEvent.cpp +++ b/gui/src/storage/AllocEvent.cpp @@ -5,26 +5,13 @@ const MemoryAddress ADDRESS_MAX = 0xffffffffffffffff; void AllocEvent::apply_to(Snapshot *snapshot) { + qDebug("Asked to apply AllocEvent to snapshot #%i . . .", snapshot->get_snapshot_id()); /* If the snapshot block tree head is NULL, then don't do anything special . . . */ if(snapshot->get_head_node() == NULL) { snapshot->set_head_node(StorageFactory::new_node(snapshot->get_snapshot_id(), (ADDRESS_MAX/2)+1)); - snapshot->get_head_node()->set_end(false); - BiTreeNode *node = snapshot->get_head_node(); - if(get_address() < node->get_address()) { - node = StorageFactory::new_node(snapshot->get_snapshot_id(), node->get_address() / 2); - snapshot->get_head_node()->set_left(node); - } - else if(get_address() >= node->get_address()) { - node = StorageFactory::new_node(snapshot->get_snapshot_id(), node->get_address() + (node->get_address() / 2)); - snapshot->get_head_node()->set_right(node); - } - else { - qWarning("NOTE: attempting to add block on node boundary . . ."); - node = StorageFactory::new_node(-1, 0); - } - node->add_block(StorageFactory::new_block(address, size)); - return; + /* Now just chain onto the other code . . . */ } + BiTreeNode *node = snapshot->get_head_node(); /* Find the correct node to split . . . */ while(true) { @@ -32,32 +19,23 @@ void AllocEvent::apply_to(Snapshot *snapshot) { node = node->get_left(); else if(node->get_right() && get_address() >= node->get_address()) node = node->get_right(); - else if(get_address() == node->get_address()) { - /* Special case: print warning and exit for now . . . */ - qFatal("NOTE: attempted to add onto block storage node boundary!"); - return; - } else break; } + + BiTreeNode *n = NULL; + + Block *block = StorageFactory::new_block(address, size); + /* Now add the new block into the correct spot . . . */ MemoryAddress diff = 0; if(node->get_parent()) diff = node->get_parent()->get_address() - node->get_address(); else diff = node->get_address(); diff /= 2; /* First, handle the special cases of a NULL left/right */ - if(node->get_right() == NULL && address > node->get_address()) { - BiTreeNode *n = StorageFactory::new_node(snapshot->get_snapshot_id(), node->get_address() - diff); - node->set_right(n); - node->set_end(false); - n->add_block(StorageFactory::new_block(get_address(), get_size())); - return; - } - else if(node->get_left() == NULL && address < node->get_address()) { - BiTreeNode *n = StorageFactory::new_node(snapshot->get_snapshot_id(), node->get_address() + diff); - node->set_left(n); - node->set_end(false); - n->add_block(StorageFactory::new_block(get_address(), get_size())); - return; + + if(node->get_left() == NULL && address < node->get_address()) { + n = StorageFactory::new_node(snapshot->get_snapshot_id(), address); + node->mark_changed(snapshot->get_snapshot_id()); } } diff --git a/gui/src/storage/BiTreeNode.cpp b/gui/src/storage/BiTreeNode.cpp index 1b86896..a4dcbc4 100644 --- a/gui/src/storage/BiTreeNode.cpp +++ b/gui/src/storage/BiTreeNode.cpp @@ -8,6 +8,13 @@ Block *BiTreeNode::get_block(MemoryAddress address) const { return NULL; } -void BiTreeNode::mark_changed(SnapshotID by_snapshot) { - +BiTreeNode *BiTreeNode::mark_changed(SnapshotID by_snapshot) { + if(snapshot_id == by_snapshot) return this; + BiTreeNode *new_node = new BiTreeNode(by_snapshot, address); + new_node->left = left; + new_node->right = right; + new_node->end = end; + new_node->block_list = block_list; + new_node->parent = parent->mark_changed(by_snapshot); + return new_node; } diff --git a/gui/src/storage/BiTreeNode.h b/gui/src/storage/BiTreeNode.h index 762b78b..5e02d29 100644 --- a/gui/src/storage/BiTreeNode.h +++ b/gui/src/storage/BiTreeNode.h @@ -37,7 +37,7 @@ public: bool is_end() const { return end; } void set_end(bool new_end) { end = new_end; } - void mark_changed(SnapshotID by_snapshot); + BiTreeNode *mark_changed(SnapshotID by_snapshot); }; #endif -- 2.11.4.GIT