- Added the "set cpu-policy" command. It`s still not useful until we initialize the pyloader plugin...

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@789 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
elvez 2006-07-21 13:10:31 +00:00
parent ddb0d99aca
commit 0dd711657f
4 changed files with 50 additions and 7 deletions

View File

@ -37,7 +37,7 @@ ConcreteSimulation::ConcreteSimulation() :
{} {}
void void
ConcreteSimulation::set_timer(const int& t) ConcreteSimulation::set_timer(unsigned int t)
{ {
_timer_interval = t; _timer_interval = t;
} }

View File

@ -39,7 +39,7 @@ namespace sgpem
void stop(); void stop();
void set_timer(const int&); void set_timer(const unsigned int);
int get_timer() const; int get_timer() const;

View File

@ -102,7 +102,7 @@ namespace sgpem
interpreted when the simulation advancement mode is continue. interpreted when the simulation advancement mode is continue.
The input value is in milliseconds, and it must be in range [0, 10000]. The input value is in milliseconds, and it must be in range [0, 10000].
*/ */
virtual void set_timer(const int&) = 0; virtual void set_timer(unsigned int) = 0;
/** /**
\see set_timer() \see set_timer()

View File

@ -677,20 +677,63 @@ TextSimulation::on_set(const Tokens& arguments)
else else
value = arguments[1]; value = arguments[1];
if(attr == "SIMULATION_TICK") if(attr == "SIMULATION-TICK")
{ {
try try
{ {
Simulation::get_instance().set_timer(string_to<int>(value)); int timer = string_to<int>(value);
if(timer < 0)
throw domain_error("");
Simulation::get_instance().set_timer(timer);
} }
catch(domain_error e) catch(domain_error e)
{ {
p_stderr(_("\nERROR: you must provide a valid integer value\n")); p_stderr(_("\nERROR: you must provide a valid unsigned integer value\n"));
} }
} }
else if(attr == "CPU-POLICY")
{
int policy;
try
{
policy = string_to<int>(value) - 1;
if(policy < 0)
throw domain_error("");
typedef vector<PolicyManager*> ManagerVec;
typedef vector<Policy*>::iterator PolicyIt;
PoliciesGatekeeper& gatekeeper = PoliciesGatekeeper::get_instance();
ManagerVec managers = gatekeeper.get_registered();
for(ManagerVec::iterator it = managers.begin(); it != managers.end(); ++it)
{
vector<Policy*> policies = (*it)->get_avail_policies();
for(PolicyIt it = policies.begin(); it != policies.end(); ++it)
{
if(policy == 0)
Simulation::get_instance().set_policy(*it);
--policy;
}
}
if(policy >= 0)
throw domain_error("");
}
catch(domain_error e)
{
p_stderr(_("\nERROR: invalid unsigned integer or not a valid policy index\n"));
}
}
else else
p_stderr(_("\nERROR: invalid attribute. Accepted are: simulation_tick\n")); p_stderr(_("\nERROR: invalid attribute. Accepted are: simulation-tick, cpu-policy\n"));
} }
void void