diff --git a/src/schedulables_tree_widget.cc b/src/schedulables_tree_widget.cc index 73a13c9..8b33b93 100644 --- a/src/schedulables_tree_widget.cc +++ b/src/schedulables_tree_widget.cc @@ -105,12 +105,12 @@ namespace sgpem return type == htype_request; } - template <> - bool - SchedulablesTreeWidget::check_type(HandleType type) - { - return type == htype_subrequest; - } +// template <> +// bool +// SchedulablesTreeWidget::check_type(HandleType type) +// { +// return type == htype_subrequest; +// } } template @@ -192,8 +192,8 @@ SchedulablesTreeWidget::on_button_press_event(GdkEventButton* event) action_group->add( Gtk::Action::create("RemoveRequest", _("Remove Request")), sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_remove_request) ); - action_group->add( Gtk::Action::create("RemoveSubrequest", _("Remove Subrequest")), - sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_remove_subrequest) ); +// action_group->add( Gtk::Action::create("RemoveSubrequest", _("Remove Subrequest")), + // sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_remove_subrequest) ); RefPtr UIManager = Gtk::UIManager::create(); UIManager->insert_action_group(action_group); @@ -224,8 +224,8 @@ SchedulablesTreeWidget::on_button_press_event(GdkEventButton* event) edits = ""; removes = ""; break; - case htype_subrequest: - removes = ""; +// case htype_subrequest: + // removes = ""; default: break; } @@ -282,7 +282,7 @@ SchedulablesTreeWidget::update(const History& history) TreeModel::Row prow = *(_model->append()); - prow[_main_column] = p.get_name(); +// prow[_main_column] = p.get_name(); prow[_types_column] = htype_process; prow[_handles_column] = &p; @@ -294,7 +294,7 @@ SchedulablesTreeWidget::update(const History& history) TreeModel::Row trow = *(_model->append(prow.children())); - trow[_main_column] = t.get_name(); +// trow[_main_column] = t.get_name(); trow[_types_column] = htype_thread; trow[_handles_column] = &t; @@ -306,29 +306,29 @@ SchedulablesTreeWidget::update(const History& history) TreeModel::Row rrow = *(_model->append(trow.children())); - std::ostringstream oss; - oss << _("request ") << ri + 1; +// std::ostringstream oss; + // oss << _("request ") << ri + 1; - rrow[_main_column] = oss.str(); +// rrow[_main_column] = oss.str(); rrow[_types_column] = htype_request; rrow[_handles_column] = &r; - vector subrequests = r.get_subrequests(); - - for(Iseq::iterator> srit = iseq(subrequests); srit; ++srit) - { - SubRequest& sr = *(*srit); - - TreeModel::Row srrow = *(_model->append(rrow.children())); - - // we are sure the key is valid, or no? - const Environment& env = history.get_last_environment(); - Resource& res = *(env.get_resources().find(sr.get_resource_key())->second); - - srrow[_main_column] = res.get_name(); - srrow[_types_column] = htype_subrequest; - srrow[_handles_column] = &sr; - } +// vector subrequests = r.get_subrequests(); +// +// for(Iseq::iterator> srit = iseq(subrequests); srit; ++srit) +// { +// SubRequest& sr = *(*srit); +// +// TreeModel::Row srrow = *(_model->append(rrow.children())); +// +// // we are sure the key is valid, or no? +// const Environment& env = history.get_last_environment(); +// Resource& res = *(env.get_resources().find(sr.get_resource_key())->second); +// +// srrow[_main_column] = res.get_name(); +// srrow[_types_column] = htype_subrequest; +// srrow[_handles_column] = &sr; +// } } } } @@ -501,7 +501,7 @@ SchedulablesTreeWidget::_on_add_request() // NOTE This is *not* reflective programming! AddRequestDialog is the name of // the base widget in the glade file. - glade->get_widget("AddRequestDialog", add_request_dialog); + glade->get_widget_derived("AddRequestDialog", add_request_dialog); Thread* t = get_selected(); assert(t != NULL); @@ -517,7 +517,7 @@ SchedulablesTreeWidget::_on_edit_request() // NOTE This is *not* reflective programming! AddRequestDialog is the name of // the base widget in the glade file. - glade->get_widget("AddRequestDialog", add_request_dialog); + glade->get_widget_derived("AddRequestDialog", add_request_dialog); Request* r = get_selected(); assert(r != NULL); @@ -552,20 +552,20 @@ SchedulablesTreeWidget::_on_remove_request() Simulation::get_instance().get_history().remove(*r); } -void -SchedulablesTreeWidget::_on_remove_subrequest() -{ - SubRequest* sr = get_selected(); - assert(sr != NULL); - - Request& owner = sr->get_request(); - - Simulation::get_instance().get_history().remove(*sr); - - // empty requests are COMPLETELY useless with the current GUI - if(owner.get_subrequests().empty()) - Simulation::get_instance().get_history().remove(owner); -} +//void +//SchedulablesTreeWidget::_on_remove_subrequest() +//{ +// SubRequest* sr = get_selected(); +// assert(sr != NULL); +// +// Request& owner = sr->get_request(); +// +// Simulation::get_instance().get_history().remove(*sr); +// +// // empty requests are COMPLETELY useless with the current GUI +// if(owner.get_subrequests().empty()) +// Simulation::get_instance().get_history().remove(owner); +//} void SchedulablesTreeWidget::_on_cell_name_data(Gtk::CellRenderer* cr, @@ -584,6 +584,9 @@ SchedulablesTreeWidget::_on_cell_name_data(Gtk::CellRenderer* cr, case htype_thread: marked_up = markup_schedulable(*get_row_handle_as(it)); break; + case htype_request: + marked_up = markup_request(*get_row_handle_as(it)); + break; default: marked_up = ""; @@ -604,16 +607,35 @@ schedulable_map_color(const Schedulable::state st) case Process::state_ready: return "yellow"; case Process::state_blocked: - return "red"; + return "Crimson"; case Process::state_terminated: - return "grey"; + return "DimGray"; case Process::state_future: - return "LightSeaGreen"; + return "LightGrey"; default: return "black"; } } +static Glib::ustring +request_map_color(const Request::state st) +{ + switch(st) + { + case Request::state_allocated: + return "green"; + case Request::state_allocable: + return "yellow"; + case Request::state_unallocable: + return "Crimson"; + case Request::state_exhausted: + return "DimGray"; + case Request::state_future: + return "LightGrey"; + default: + return "black"; + } +} ustring SchedulablesTreeWidget::markup_schedulable(const Schedulable& s) @@ -636,3 +658,34 @@ SchedulablesTreeWidget::markup_schedulable(const Schedulable& s) return oss.str(); } +ustring +SchedulablesTreeWidget::markup_request(Request& r) +{ + using std::ostringstream; + using std::endl; + + ostringstream oss; + + oss << "" + << _("at ") << r.get_instant() << ":"; + + const Environment& env = Simulation::get_instance().get_history().get_last_environment(); + const Environment::Resources& resources = env.get_resources(); + std::vector subrequests = r.get_subrequests(); + + for(Iseq::iterator> it = iseq(subrequests); it; ++it) + { + SubRequest& sr = *(*it); + Resource& res = *(resources.find(sr.get_resource_key())->second); + + oss << "" + << " -> " << res.get_name() << " (" + << (sr.get_length() - sr.get_remaining_time()) + << "/" << sr.get_length() << ")"; + } + + oss << ""; + + return oss.str(); +} + diff --git a/src/schedulables_tree_widget.hh b/src/schedulables_tree_widget.hh index b9ea409..aae1898 100644 --- a/src/schedulables_tree_widget.hh +++ b/src/schedulables_tree_widget.hh @@ -27,6 +27,7 @@ namespace sgpem class Process; class Thread; class AddRequestDialog; + class Request; } #include "config.h" @@ -65,7 +66,7 @@ namespace sgpem htype_process, htype_thread, htype_request, - htype_subrequest, + // htype_subrequest, htype_undefined }; @@ -101,12 +102,13 @@ namespace sgpem void _on_remove_process(); void _on_remove_thread(); void _on_remove_request(); - void _on_remove_subrequest(); +// void _on_remove_subrequest(); void _on_cell_name_data(Gtk::CellRenderer* cr, const Gtk::TreeModel::iterator& it); Glib::ustring markup_schedulable(const Schedulable& s); + Glib::ustring markup_request(Request& s); Glib::RefPtr _model; Gtk::TreeModelColumnRecord _columns;