- Fix the bug about reconfiguring a policy don't resetting the

History the Hard Way(tm)


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1026 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-09-06 16:33:39 +00:00
parent cb1d85a4cc
commit 22dded7243
5 changed files with 31 additions and 12 deletions

View File

@ -488,6 +488,13 @@ ConcreteHistory::edit_subrequest(SubRequest& subrequest,
} }
void
ConcreteHistory::reset()
{
reset(true);
}
void void
ConcreteHistory::set_front(position p) ConcreteHistory::set_front(position p)
{ {

View File

@ -117,7 +117,8 @@ namespace sgpem
// (Returns if the History was sealed before this call) // (Returns if the History was sealed before this call)
bool seal(); bool seal();
virtual void reset(bool notify = true); void reset(); // Implements a virtual method
void reset(bool notify); // Only available in this class
protected: protected:
typedef std::vector<ConcreteEnvironment*> Snapshots; typedef std::vector<ConcreteEnvironment*> Snapshots;

View File

@ -144,6 +144,8 @@ namespace sgpem
*/ */
virtual bool set_notify_enabled(bool enabled = true); virtual bool set_notify_enabled(bool enabled = true);
virtual void reset() = 0;
protected: protected:
typedef std::vector<HistoryObserver*> RegisteredObservers; typedef std::vector<HistoryObserver*> RegisteredObservers;
RegisteredObservers _observers; RegisteredObservers _observers;

View File

@ -291,7 +291,8 @@ GuiBuilder::on_configure_cpu_policy()
{ {
using namespace Gtk; using namespace Gtk;
CPUPolicy* policy = Simulation::get_instance().get_policy(); Simulation& sim = Simulation::get_instance();
CPUPolicy* policy = sim.get_policy();
if(policy == NULL) if(policy == NULL)
{ {
@ -299,13 +300,17 @@ GuiBuilder::on_configure_cpu_policy()
_("<b>No CPU policy is currently selected.</b>\nPlease choose one before trying to configure it."), _("<b>No CPU policy is currently selected.</b>\nPlease choose one before trying to configure it."),
true, MESSAGE_WARNING, BUTTONS_OK, true); true, MESSAGE_WARNING, BUTTONS_OK, true);
warn.run(); warn.run();
return;
} }
PolicyParameters& params = policy->get_parameters(); PolicyParameters& params = policy->get_parameters();
ConfigurePolicyDialog config_dialog(_("Configuring CPU Policy ") + policy->get_name(), ConfigurePolicyDialog config_dialog(_("Configuring CPU Policy ") + policy->get_name(),
get_initial_window(), policy->get_description(), params); get_initial_window(), policy->get_description(), params);
config_dialog.run();
if(config_dialog.run() == RESPONSE_OK)
{
sim.stop();
sim.get_history().reset();
}
} }
@ -314,7 +319,8 @@ GuiBuilder::on_configure_resource_policy()
{ {
using namespace Gtk; using namespace Gtk;
ResourcePolicy* policy = Simulation::get_instance().get_resource_policy(); Simulation& sim = Simulation::get_instance();
ResourcePolicy* policy = sim.get_resource_policy();
if(policy == NULL) if(policy == NULL)
{ {
@ -328,7 +334,12 @@ GuiBuilder::on_configure_resource_policy()
PolicyParameters& params = policy->get_parameters(); PolicyParameters& params = policy->get_parameters();
ConfigurePolicyDialog config_dialog(_("Configuring CPU Policy ") + policy->get_name(), ConfigurePolicyDialog config_dialog(_("Configuring CPU Policy ") + policy->get_name(),
get_initial_window(), policy->get_description(), params); get_initial_window(), policy->get_description(), params);
config_dialog.run();
if(config_dialog.run() == RESPONSE_OK)
{
sim.stop();
sim.get_history().reset();
}
} }

View File

@ -42,8 +42,6 @@ SimulationWidget::SimulationWidget(Simulation& simulation)
_simulation(&simulation), _simulation(&simulation),
_x_unit(10), _y_unit(10), _x_unit(10), _y_unit(10),
_n_proc(0), _n_thr(0) _n_proc(0), _n_thr(0)
{ {
// Register this SimulationObserver: // Register this SimulationObserver:
_simulation->attach(*this); _simulation->attach(*this);
@ -224,7 +222,7 @@ SimulationWidget::draw_grid(cairo_t* ctx)
// std::cout << " SimulationWidget::draw_grid p=" << _n_proc << " t=" << _n_thr << std::endl; // std::cout << " SimulationWidget::draw_grid p=" << _n_proc << " t=" << _n_thr << std::endl;
// useful constants // useful constants
const History& hist = _simulation->get_history(); const History& hist = _simulation->get_history();
//const int hist_size = hist.get_size();
const unsigned int hist_front = hist.get_front(); const unsigned int hist_front = hist.get_front();
const double top_margin = _yu_top_margin * _y_unit; const double top_margin = _yu_top_margin * _y_unit;
// const double left_margin = _x_unit; // const double left_margin = _x_unit;