- Removed a level from the schedulables tree. Added details about subrequests
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@973 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
323ab51210
commit
0c3ecf3bcb
|
@ -105,12 +105,12 @@ namespace sgpem
|
|||
return type == htype_request;
|
||||
}
|
||||
|
||||
template <>
|
||||
bool
|
||||
SchedulablesTreeWidget::check_type<SubRequest>(HandleType type)
|
||||
{
|
||||
return type == htype_subrequest;
|
||||
}
|
||||
// template <>
|
||||
// bool
|
||||
// SchedulablesTreeWidget::check_type<SubRequest>(HandleType type)
|
||||
// {
|
||||
// return type == htype_subrequest;
|
||||
// }
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -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> UIManager = Gtk::UIManager::create();
|
||||
UIManager->insert_action_group(action_group);
|
||||
|
@ -224,8 +224,8 @@ SchedulablesTreeWidget::on_button_press_event(GdkEventButton* event)
|
|||
edits = "<menuitem action='EditRequest'/>";
|
||||
removes = "<menuitem action='RemoveRequest'/>";
|
||||
break;
|
||||
case htype_subrequest:
|
||||
removes = "<menuitem action='RemoveSubrequest'/>";
|
||||
// case htype_subrequest:
|
||||
// removes = "<menuitem action='RemoveSubrequest'/>";
|
||||
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<SubRequest*> subrequests = r.get_subrequests();
|
||||
|
||||
for(Iseq<vector<SubRequest*>::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<SubRequest*> subrequests = r.get_subrequests();
|
||||
//
|
||||
// for(Iseq<vector<SubRequest*>::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<Thread>();
|
||||
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<Request>();
|
||||
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<SubRequest>();
|
||||
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<SubRequest>();
|
||||
// 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<Thread>(it));
|
||||
break;
|
||||
case htype_request:
|
||||
marked_up = markup_request(*get_row_handle_as<Request>(it));
|
||||
break;
|
||||
|
||||
default:
|
||||
marked_up = "<small>";
|
||||
|
@ -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 << "<small><span foreground=\"" << request_map_color(r.get_state()) << "\"><b>"
|
||||
<< _("at ") << r.get_instant() << ":</b></span>";
|
||||
|
||||
const Environment& env = Simulation::get_instance().get_history().get_last_environment();
|
||||
const Environment::Resources& resources = env.get_resources();
|
||||
std::vector<SubRequest*> subrequests = r.get_subrequests();
|
||||
|
||||
for(Iseq<std::vector<SubRequest*>::iterator> it = iseq(subrequests); it; ++it)
|
||||
{
|
||||
SubRequest& sr = *(*it);
|
||||
Resource& res = *(resources.find(sr.get_resource_key())->second);
|
||||
|
||||
oss << "<span foreground=\"" << request_map_color(sr.get_state()) << "\">"
|
||||
<< " -> </span>" << res.get_name() << " ("
|
||||
<< (sr.get_length() - sr.get_remaining_time())
|
||||
<< "/" << sr.get_length() << ")";
|
||||
}
|
||||
|
||||
oss << "</small>";
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Gtk::TreeStore> _model;
|
||||
Gtk::TreeModelColumnRecord _columns;
|
||||
|
|
Loading…
Reference in New Issue