- Simplify a little sequences' interface
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1028 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
c62734ef59
commit
8e20f5499f
|
@ -189,7 +189,7 @@ AddRequestDialog::update_combo()
|
|||
|
||||
_combo_model->clear();
|
||||
|
||||
for(Iseq<ResourceIt> it = const_iseq(resources); it; ++it)
|
||||
for(Iseq<ResourceIt> it = iseq(resources); it; ++it)
|
||||
{
|
||||
TreeModel::Row row = *(_combo_model->append());
|
||||
row[_combo_key_column] = it->first;
|
||||
|
|
|
@ -60,7 +60,7 @@ ConcreteEnvironment::ConcreteEnvironment(const ConcreteEnvironment& ce) :
|
|||
{
|
||||
const Processes& ce_proc = ce._processes;
|
||||
insert_iterator<Processes> dest(_processes, _processes.begin());
|
||||
for (Iseq<Processes::const_iterator> orig = const_iseq(ce_proc); orig; orig++)
|
||||
for (Iseq<Processes::const_iterator> orig = iseq(ce_proc); orig; orig++)
|
||||
*dest++ = new DynamicProcess(dynamic_cast<const DynamicProcess&>(**orig));
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ DynamicProcess::DynamicProcess(const DynamicProcess &other) :
|
|||
Schedulable(), DynamicSchedulable(other), Process(),
|
||||
_core(other._core)
|
||||
{
|
||||
for (Iseq<ConstThreadIt> seq = const_iseq(other._dynamic_threads); seq; ++seq)
|
||||
for (Iseq<ConstThreadIt> seq = iseq(other._dynamic_threads); seq; ++seq)
|
||||
new DynamicThread(*(*seq), this);
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ DynamicProcess::get_state() const
|
|||
// state_terminated.
|
||||
|
||||
|
||||
for(Iseq<ConstThreadIt> seq = const_iseq(_dynamic_threads); seq; ++seq)
|
||||
for(Iseq<ConstThreadIt> 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<ConstThreadIt> seq = const_iseq(_dynamic_threads); seq; ++seq)
|
||||
for (Iseq<ConstThreadIt> 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<ConstThreadIt> seq = const_iseq(_dynamic_threads); seq; ++seq)
|
||||
for (Iseq<ConstThreadIt> 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<ConstThreadIt> seq = const_iseq(_dynamic_threads); seq; ++seq)
|
||||
for (Iseq<ConstThreadIt> seq = iseq(_dynamic_threads); seq; ++seq)
|
||||
{
|
||||
int acq = (*seq)->get_last_release();
|
||||
if (result < acq)
|
||||
|
|
|
@ -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<Process*>& procs,
|
|||
Threads& collected_threads)
|
||||
{
|
||||
collected_threads.clear();
|
||||
for (Iseq<vector<Process*>::const_iterator> seq = const_iseq(procs); seq; ++seq)
|
||||
for (Iseq<vector<Process*>::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<Threads::const_iterator> seq = const_iseq(all_threads); seq; ++seq)
|
||||
for (Iseq<Threads::const_iterator> 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<SubRequests::const_iterator> it_dsrs = const_iseq(subreqs); it_dsrs; ++it_dsrs)
|
||||
{
|
||||
{
|
||||
const SubRequests& const_subreqs = subreqs;
|
||||
for(Iseq<SubRequests::const_iterator> 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)
|
||||
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<SubRequestQueue::const_iterator> queue_it = const_iseq(queue);
|
||||
const SubRequestQueue& const_queue = queue;
|
||||
for(Iseq<SubRequestQueue::const_iterator> 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<SubRequestQueue::const_iterator> queue_it = const_iseq(queue);
|
||||
for(Iseq<SubRequestQueue::const_iterator> queue_it = iseq(queue);
|
||||
queue_it; queue_it++, position_in_queue++)
|
||||
{
|
||||
DynamicSubRequest& sr = (DynamicSubRequest&) **queue_it;
|
||||
|
|
|
@ -80,7 +80,7 @@ ConfigurePolicyDialog::ConfigurePolicyDialog(const Glib::ustring& title,
|
|||
intframe.add(*_table_int);
|
||||
|
||||
row_n = 0;
|
||||
for(Iseq<IntParams::const_iterator> it = const_iseq(intpars); it; ++it, ++row_n)
|
||||
for(Iseq<IntParams::const_iterator> 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<FloatParams::const_iterator> it = const_iseq(floatpars); it; ++it, ++row_n)
|
||||
for(Iseq<FloatParams::const_iterator> 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<StringParams::const_iterator> it = const_iseq(stringpars); it; ++it, ++row_n)
|
||||
for(Iseq<StringParams::const_iterator> 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<Table::TableList::const_reverse_iterator> it = const_riseq(list); it; ++it)
|
||||
for(Iseq<Table::TableList::const_reverse_iterator> 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<Table::TableList::const_reverse_iterator> it = const_riseq(list); it; ++it)
|
||||
for(Iseq<Table::TableList::const_reverse_iterator> 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<Table::TableList::const_reverse_iterator> it = const_riseq(list); it; ++it)
|
||||
for(Iseq<Table::TableList::const_reverse_iterator> it = riseq(list); it; ++it)
|
||||
{
|
||||
Widget* w;
|
||||
|
||||
|
|
|
@ -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<Managers::const_iterator> m_it = const_iseq(managers); m_it; ++m_it)
|
||||
for(Iseq<Managers::const_iterator> m_it = iseq(managers); m_it; ++m_it)
|
||||
{
|
||||
const Policies& policies = (*m_it)->get_avail_policies();
|
||||
for(Iseq<Policies::const_iterator> p_it = const_iseq(policies); p_it; ++p_it)
|
||||
for(Iseq<Policies::const_iterator> 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<Managers::const_iterator> m_it = const_iseq(managers); m_it; ++m_it)
|
||||
for(Iseq<Managers::const_iterator> m_it = iseq(managers); m_it; ++m_it)
|
||||
{
|
||||
const Policies& policies = (*m_it)->get_avail_policies();
|
||||
for(Iseq<Policies::const_iterator> p_it = const_iseq(policies); p_it; ++p_it)
|
||||
for(Iseq<Policies::const_iterator> 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));
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -161,7 +161,7 @@ ResourcesWidget::update(const History& history)
|
|||
|
||||
_model->clear();
|
||||
|
||||
for(Iseq<ResourceIt> it = const_iseq(resources); it; ++it)
|
||||
for(Iseq<ResourceIt> 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<Environment::SubRequestQueue::const_iterator> it = const_iseq(queue); it; ++it)
|
||||
for(Iseq<Environment::SubRequestQueue::const_iterator> it = iseq(queue); it; ++it)
|
||||
{
|
||||
SubRequest& sr = *(*it);
|
||||
|
||||
|
|
|
@ -278,7 +278,7 @@ SchedulablesTreeWidget::update(const History& history)
|
|||
_model->clear();
|
||||
|
||||
|
||||
for(Iseq<ProcessIt> pit = const_iseq(processes); pit; ++pit)
|
||||
for(Iseq<ProcessIt> pit = iseq(processes); pit; ++pit)
|
||||
{
|
||||
Process& p = *(*pit);
|
||||
|
||||
|
@ -336,7 +336,8 @@ SchedulablesTreeWidget::update(const History& history)
|
|||
}
|
||||
|
||||
// Restore expanded rows
|
||||
for(Iseq<vector<Glib::ustring>::const_iterator> it = const_iseq(_expanded_rows); it; ++it)
|
||||
const vector<Glib::ustring>& const_expanded_rows = _expanded_rows;
|
||||
for(Iseq<vector<Glib::ustring>::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<Environment::Processes::const_iterator> pit = const_iseq(processes); pit; ++pit)
|
||||
for(Iseq<Environment::Processes::const_iterator> pit = iseq(processes); pit; ++pit)
|
||||
{
|
||||
vector<Thread*> threads = (*pit)->get_threads();
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<class Container>
|
||||
Iseq<typename Container::const_iterator>
|
||||
const_iseq(const Container& c)
|
||||
iseq(const Container& c)
|
||||
{
|
||||
return Iseq<typename Container::const_iterator>(c.begin(), c.end());
|
||||
}
|
||||
|
@ -89,7 +83,7 @@ iseq(Container& c)
|
|||
|
||||
template<class Container>
|
||||
Iseq<typename Container::const_reverse_iterator>
|
||||
const_riseq(const Container& c)
|
||||
riseq(const Container& c)
|
||||
{
|
||||
return Iseq<typename Container::const_reverse_iterator>(c.rbegin(), c.rend());
|
||||
}
|
||||
|
@ -101,4 +95,3 @@ riseq(Container& c)
|
|||
{
|
||||
return Iseq<typename Container::reverse_iterator>(c.rbegin(), c.rend());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue