diff --git a/src/add_request_dialog.cc b/src/add_request_dialog.cc index fc1f76b..5bfba19 100644 --- a/src/add_request_dialog.cc +++ b/src/add_request_dialog.cc @@ -189,7 +189,7 @@ AddRequestDialog::update_combo() _combo_model->clear(); - for(Iseq it = const_iseq(resources); it; ++it) + for(Iseq it = iseq(resources); it; ++it) { TreeModel::Row row = *(_combo_model->append()); row[_combo_key_column] = it->first; diff --git a/src/backend/concrete_environment.cc b/src/backend/concrete_environment.cc index b656f9c..4f9488e 100644 --- a/src/backend/concrete_environment.cc +++ b/src/backend/concrete_environment.cc @@ -60,7 +60,7 @@ ConcreteEnvironment::ConcreteEnvironment(const ConcreteEnvironment& ce) : { const Processes& ce_proc = ce._processes; insert_iterator dest(_processes, _processes.begin()); - for (Iseq orig = const_iseq(ce_proc); orig; orig++) + for (Iseq orig = iseq(ce_proc); orig; orig++) *dest++ = new DynamicProcess(dynamic_cast(**orig)); } diff --git a/src/backend/dynamic_process.cc b/src/backend/dynamic_process.cc index b144819..15aae4f 100644 --- a/src/backend/dynamic_process.cc +++ b/src/backend/dynamic_process.cc @@ -48,7 +48,7 @@ DynamicProcess::DynamicProcess(const DynamicProcess &other) : Schedulable(), DynamicSchedulable(other), Process(), _core(other._core) { - for (Iseq seq = const_iseq(other._dynamic_threads); seq; ++seq) + for (Iseq seq = iseq(other._dynamic_threads); seq; ++seq) new DynamicThread(*(*seq), this); } @@ -97,7 +97,7 @@ DynamicProcess::get_state() const // state_terminated. - for(Iseq seq = const_iseq(_dynamic_threads); seq; ++seq) + for(Iseq seq = iseq(_dynamic_threads); seq; ++seq) { state thread_state = (*seq)->get_state(); @@ -170,7 +170,7 @@ unsigned int DynamicProcess::get_elapsed_time() const { unsigned int result = 0; - for (Iseq seq = const_iseq(_dynamic_threads); seq; ++seq) + for (Iseq seq = iseq(_dynamic_threads); seq; ++seq) { result += (*seq)->get_elapsed_time(); } @@ -181,7 +181,7 @@ int DynamicProcess::get_last_acquisition() const { int result = -1; - for (Iseq seq = const_iseq(_dynamic_threads); seq; ++seq) + for (Iseq seq = iseq(_dynamic_threads); seq; ++seq) { int acq = (*seq)->get_last_acquisition(); if (result < acq) @@ -194,7 +194,7 @@ int DynamicProcess::get_last_release() const { int result = -1; - for (Iseq seq = const_iseq(_dynamic_threads); seq; ++seq) + for (Iseq seq = iseq(_dynamic_threads); seq; ++seq) { int acq = (*seq)->get_last_release(); if (result < acq) diff --git a/src/backend/scheduler.cc b/src/backend/scheduler.cc index 221b15b..8054af6 100644 --- a/src/backend/scheduler.cc +++ b/src/backend/scheduler.cc @@ -19,7 +19,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -// DISCLAIMER FOR THE RAMPANT CODER: + // DISCLAIMER FOR THE RAMPANT CODER: \\ // ----------------------------------------------------\\ // ``If you touch this code, your ass is grass, \\ // and I'm the lawnmover.'' \\ @@ -70,7 +70,7 @@ static void raise_new_requests(DynamicThread& running_thread, ConcreteEnvironmen static void look_for_mutant_request_states(ConcreteEnvironment& environment, unsigned int& alive_threads); static void determine_subr_allocable_status(const DynamicRequest& req, DynamicSubRequest& subr, const Resource& res, SubRequestQueue& queue); -static void determine_subr_allocable_status(const Resource& res, SubRequestQueue& queue); +static void determine_subr_allocable_status(const Resource& res, const SubRequestQueue& queue); // --------------------------------------------------------- @@ -89,7 +89,7 @@ collect_threads(const std::vector& procs, Threads& collected_threads) { collected_threads.clear(); - for (Iseq::const_iterator> seq = const_iseq(procs); seq; ++seq) + for (Iseq::const_iterator> seq = iseq(procs); seq; ++seq) { const Threads& ts = ((DynamicProcess&) **seq).get_dynamic_threads(); collected_threads.insert(collected_threads.end(), ts.begin(), ts.end()); @@ -103,7 +103,7 @@ prepare_ready_queue(ConcreteEnvironment& snapshot, { ReadyQueue& queue = snapshot.get_sorted_queue(); assert(queue.size() == 0); - for (Iseq seq = const_iseq(all_threads); seq; ++seq) + for (Iseq seq = iseq(all_threads); seq; ++seq) { if ((*seq)->get_state() == Schedulable::state_ready) queue.append(**seq); @@ -228,27 +228,30 @@ raise_new_requests(DynamicThread& running_thread, ConcreteEnvironment& environme switch(cur_req.get_state()) { case Request::state_allocable: - for(Iseq it_dsrs = const_iseq(subreqs); it_dsrs; ++it_dsrs) - { - - DynamicSubRequest& subreq = **it_dsrs; - assert(subreq.get_state() == Request::state_allocable); -/* - // Move this request up the queue, to the back of the allocated - // subrequests. This is mainly for display. :-) - // The rest of the queue sorting business is up to the resource policy. - Environment::resource_key_t rkey = subreq.get_resource_key(); - SubRequestQueue& queue = environment.get_request_queue(rkey); - assert(queue.size() > 0); - SubRequestQueue::iterator alloc_it = queue.begin(); - for(; (*alloc_it)->get_state() == Request::state_allocated; ++alloc_it) + { + const SubRequests& const_subreqs = subreqs; + for(Iseq it_dsrs = iseq(const_subreqs); it_dsrs; ++it_dsrs) + { + + DynamicSubRequest& subreq = **it_dsrs; + assert(subreq.get_state() == Request::state_allocable); + /* + // Move this request up the queue, to the back of the allocated + // subrequests. This is mainly for display. :-) + // The rest of the queue sorting business is up to the resource policy. + Environment::resource_key_t rkey = subreq.get_resource_key(); + SubRequestQueue& queue = environment.get_request_queue(rkey); + assert(queue.size() > 0); + SubRequestQueue::iterator alloc_it = queue.begin(); + for(; (*alloc_it)->get_state() == Request::state_allocated; ++alloc_it) assert(alloc_it != queue.end()); // We cannot reach the end without having found the current subr! - SubRequestQueue::iterator this_subreq = find(alloc_it, queue.end(), &subreq); - assert(this_subreq != queue.end()); - swap(*alloc_it, *this_subreq); -*/ - subreq.set_state(Request::state_allocated); - } + SubRequestQueue::iterator this_subreq = find(alloc_it, queue.end(), &subreq); + assert(this_subreq != queue.end()); + swap(*alloc_it, *this_subreq); + */ + subreq.set_state(Request::state_allocated); + } + } break; case Request::state_unallocable: @@ -278,7 +281,8 @@ determine_subr_allocable_status(const DynamicRequest& req, DynamicSubRequest& su unsigned int position_in_queue = 0; bool too_far_in_the_queue = false; - for(Iseq queue_it = const_iseq(queue); + const SubRequestQueue& const_queue = queue; + for(Iseq queue_it = iseq(const_queue); queue_it && free_places >= needed_places; queue_it++, position_in_queue++) { SubRequest& sr = **queue_it; @@ -329,11 +333,11 @@ determine_subr_allocable_status(const DynamicRequest& req, DynamicSubRequest& su // The following loop updates the states of the subrequests depending // on their position in the queue void -determine_subr_allocable_status(const Resource& res, SubRequestQueue& queue) +determine_subr_allocable_status(const Resource& res, const SubRequestQueue& queue) { unsigned int total_places = res.get_places(); unsigned int position_in_queue = 0; - for(Iseq queue_it = const_iseq(queue); + for(Iseq queue_it = iseq(queue); queue_it; queue_it++, position_in_queue++) { DynamicSubRequest& sr = (DynamicSubRequest&) **queue_it; diff --git a/src/configure_policy_dialog.cc b/src/configure_policy_dialog.cc index aa4e231..80a4150 100644 --- a/src/configure_policy_dialog.cc +++ b/src/configure_policy_dialog.cc @@ -80,7 +80,7 @@ ConfigurePolicyDialog::ConfigurePolicyDialog(const Glib::ustring& title, intframe.add(*_table_int); row_n = 0; - for(Iseq it = const_iseq(intpars); it; ++it, ++row_n) + for(Iseq it = iseq(intpars); it; ++it, ++row_n) parameter_int(it->second, row_n); } @@ -98,7 +98,7 @@ ConfigurePolicyDialog::ConfigurePolicyDialog(const Glib::ustring& title, floatframe.add(*_table_float); row_n = 0; - for(Iseq it = const_iseq(floatpars); it; ++it, ++row_n) + for(Iseq it = iseq(floatpars); it; ++it, ++row_n) parameter_float(it->second, row_n); } @@ -115,7 +115,7 @@ ConfigurePolicyDialog::ConfigurePolicyDialog(const Glib::ustring& title, stringframe.add(*_table_string); row_n = 0; - for(Iseq it = const_iseq(stringpars); it; ++it, ++row_n) + for(Iseq it = iseq(stringpars); it; ++it, ++row_n) parameter_string(it->second, row_n); } @@ -199,7 +199,7 @@ ConfigurePolicyDialog::on_okay() // (cannot) fixme: Using a reverse iterator makes me feel REALLY uneasy... // what if the implementation changes between different gtk+ versions? - for(Iseq it = const_riseq(list); it; ++it) + for(Iseq it = riseq(list); it; ++it) { Widget* w; @@ -221,7 +221,7 @@ ConfigurePolicyDialog::on_okay() // (cannot) fixme: Using a reverse iterator makes me feel REALLY uneasy... // what if the implementation changes between different gtk+ versions? - for(Iseq it = const_riseq(list); it; ++it) + for(Iseq it = riseq(list); it; ++it) { Widget* w; @@ -243,7 +243,7 @@ ConfigurePolicyDialog::on_okay() // (cannot) fixme: Using a reverse iterator makes me feel REALLY uneasy... // what if the implementation changes between different gtk+ versions? - for(Iseq it = const_riseq(list); it; ++it) + for(Iseq it = riseq(list); it; ++it) { Widget* w; diff --git a/src/gui_builder.cc b/src/gui_builder.cc index f797d6d..3579892 100644 --- a/src/gui_builder.cc +++ b/src/gui_builder.cc @@ -360,10 +360,10 @@ GuiBuilder::populate_with_cpu_policies(Gtk::Menu& menu) CPUPoliciesGatekeeper& pgk = CPUPoliciesGatekeeper::get_instance(); const Managers& managers = pgk.get_registered(); - for(Iseq m_it = const_iseq(managers); m_it; ++m_it) + for(Iseq m_it = iseq(managers); m_it; ++m_it) { const Policies& policies = (*m_it)->get_avail_policies(); - for(Iseq p_it = const_iseq(policies); p_it; ++p_it) + for(Iseq p_it = iseq(policies); p_it; ++p_it) { RadioMenuItem& menuitem = *manage(new RadioMenuItem(group, (*p_it)->get_name())); menuitem.signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &GuiBuilder::on_selected_cpu_policy), *p_it)); @@ -426,10 +426,10 @@ GuiBuilder::populate_with_resource_policies(Gtk::Menu& menu) ResourcePoliciesGatekeeper& pgk = ResourcePoliciesGatekeeper::get_instance(); const Managers& managers = pgk.get_registered(); - for(Iseq m_it = const_iseq(managers); m_it; ++m_it) + for(Iseq m_it = iseq(managers); m_it; ++m_it) { const Policies& policies = (*m_it)->get_avail_policies(); - for(Iseq p_it = const_iseq(policies); p_it; ++p_it) + for(Iseq p_it = iseq(policies); p_it; ++p_it) { RadioMenuItem& menuitem = *manage(new RadioMenuItem(group, (*p_it)->get_name())); menuitem.signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &GuiBuilder::on_selected_resource_policy), *p_it)); diff --git a/src/holt_widget.cc b/src/holt_widget.cc index 84da713..a516892 100644 --- a/src/holt_widget.cc +++ b/src/holt_widget.cc @@ -169,24 +169,6 @@ void HoltSchedulable::draw(cairo_t *cr) cairo_pattern_t* gradient; gradient = cairo_pattern_create_radial( _pos.real(), _pos.imag(), 0.0, _pos.real(), _pos.imag(), _radius); - - -/* - _ready_process_gradient = cairo_pattern_create_linear(0, 0, 0, _yu_process_bar_height * _y_unit); - // yellow - cairo_pattern_add_color_stop_rgba(_ready_process_gradient, 0.00, 1.0, 1.0, 0.5, 0.7); - cairo_pattern_add_color_stop_rgba(_ready_process_gradient, 1.00, 1.0, 1.0, 0.0, 1.0); - - _running_process_gradient = cairo_pattern_create_linear(0, 0, 0, _yu_process_bar_height * _y_unit); - // green - cairo_pattern_add_color_stop_rgba(_running_process_gradient, 0.00, 0.5, 1.0, 0.5, 0.7); - cairo_pattern_add_color_stop_rgba(_running_process_gradient, 1.00, 0.0, 1.0, 0.0, 1.0); - - _blocked_process_gradient = cairo_pattern_create_linear(0, 0, 0, _yu_process_bar_height * _y_unit); - // blue - cairo_pattern_add_color_stop_rgba(_blocked_process_gradient, 0.00, 0.5, 0.5, 1.0, 0.7); - cairo_pattern_add_color_stop_rgba(_blocked_process_gradient, 1.00, 0.0, 0.0, 1.0, 1.0); -*/ // draw circle cairo_arc (cr, _pos.real(), _pos.imag(), _radius, 0, 2 * M_PI); // filling diff --git a/src/resources_widget.cc b/src/resources_widget.cc index f638983..cd10bfa 100644 --- a/src/resources_widget.cc +++ b/src/resources_widget.cc @@ -161,7 +161,7 @@ ResourcesWidget::update(const History& history) _model->clear(); - for(Iseq it = const_iseq(resources); it; ++it) + for(Iseq it = iseq(resources); it; ++it) { Resource& r = *(it->second); @@ -289,7 +289,7 @@ ResourcesWidget::_on_cell_name_data(Gtk::CellRenderer* cr, const Environment::SubRequestQueue& queue = env.get_request_queue(key); - for(Iseq it = const_iseq(queue); it; ++it) + for(Iseq it = iseq(queue); it; ++it) { SubRequest& sr = *(*it); diff --git a/src/schedulables_tree_widget.cc b/src/schedulables_tree_widget.cc index 412beff..f793dbb 100644 --- a/src/schedulables_tree_widget.cc +++ b/src/schedulables_tree_widget.cc @@ -278,7 +278,7 @@ SchedulablesTreeWidget::update(const History& history) _model->clear(); - for(Iseq pit = const_iseq(processes); pit; ++pit) + for(Iseq pit = iseq(processes); pit; ++pit) { Process& p = *(*pit); @@ -336,7 +336,8 @@ SchedulablesTreeWidget::update(const History& history) } // Restore expanded rows - for(Iseq::const_iterator> it = const_iseq(_expanded_rows); it; ++it) + const vector& const_expanded_rows = _expanded_rows; + for(Iseq::const_iterator> it = iseq(const_expanded_rows); it; ++it) expand_row(Gtk::TreeModel::Path(*it), false); // We can clear it now, since until next update we won't need it. @@ -533,7 +534,7 @@ SchedulablesTreeWidget::_on_edit_request() const Environment::Processes& processes = Simulation::get_instance().get_history().get_environment_at(0).get_processes(); - for(Iseq pit = const_iseq(processes); pit; ++pit) + for(Iseq pit = iseq(processes); pit; ++pit) { vector threads = (*pit)->get_threads(); diff --git a/src/simulation_widget.cc b/src/simulation_widget.cc index 5ccb854..d91b4d6 100644 --- a/src/simulation_widget.cc +++ b/src/simulation_widget.cc @@ -18,6 +18,8 @@ // along with SGPEMv2; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#include "gettext.h" + #include "simulation_widget.hh" #include "cairo_elements.hh" @@ -148,8 +150,8 @@ SimulationWidget::draw_widget(cairo_t* ctx) { if(_n_proc<1) // nothing to draw { - cairo_move_to(ctx, 10.0, 10.0); - cairo_show_text(ctx, "Simulation Widget: nothing to draw..."); + cairo_move_to(ctx, 20.0, 20.0); + cairo_show_text(ctx, _("Nothing to see here... add some processes! Right-click on the Schedulables view in this window.")); return; } diff --git a/src/templates/sequences.tcc b/src/templates/sequences.tcc index b1727c4..18b8107 100644 --- a/src/templates/sequences.tcc +++ b/src/templates/sequences.tcc @@ -57,12 +57,6 @@ public: bool operator!=(const Iseq& i) const { return Iseq::first != i.first; } - -// bool operator==(const In& i) const -// { return Iseq::first == i; } - -// bool operator!=(const In& i) const -// { return Iseq::first != i; } }; @@ -71,7 +65,7 @@ public: template Iseq -const_iseq(const Container& c) +iseq(const Container& c) { return Iseq(c.begin(), c.end()); } @@ -89,7 +83,7 @@ iseq(Container& c) template Iseq -const_riseq(const Container& c) +riseq(const Container& c) { return Iseq(c.rbegin(), c.rend()); } @@ -101,4 +95,3 @@ riseq(Container& c) { return Iseq(c.rbegin(), c.rend()); } -