- Fixed linking problem with visibility enabled caused by TextSimulation accessing (stupidly) Dynamic* objects
- Removed a bunch of FIXME from text_simulation.cc, now TextSimulation fully cooperates with Environment and History git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@774 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
a092f3dc7b
commit
f4b255d31c
|
@ -169,7 +169,17 @@ ConcreteSimulation::run() throw(UserInterruptException)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Simulation::state
|
||||||
|
ConcreteSimulation::get_state() const
|
||||||
|
{
|
||||||
|
return _state;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConcreteHistory&
|
||||||
|
ConcreteSimulation::get_history()
|
||||||
|
{
|
||||||
|
return _history;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ConcreteSimulation::set_policy(Policy* p)
|
ConcreteSimulation::set_policy(Policy* p)
|
||||||
|
|
|
@ -47,8 +47,12 @@ namespace sgpem
|
||||||
|
|
||||||
bool get_mode() const;
|
bool get_mode() const;
|
||||||
|
|
||||||
|
state get_state() const;
|
||||||
|
|
||||||
void set_policy(Policy*);
|
void set_policy(Policy*);
|
||||||
|
|
||||||
|
ConcreteHistory& get_history();
|
||||||
|
|
||||||
Policy* get_policy();
|
Policy* get_policy();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -25,6 +25,7 @@ namespace sgpem
|
||||||
{
|
{
|
||||||
class ConcreteSimulation;
|
class ConcreteSimulation;
|
||||||
class Policy;
|
class Policy;
|
||||||
|
class History;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -125,10 +126,10 @@ namespace sgpem
|
||||||
*/
|
*/
|
||||||
virtual bool get_mode() const = 0;
|
virtual bool get_mode() const = 0;
|
||||||
|
|
||||||
|
virtual state get_state() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Setup the policy to be used by the system.
|
\brief Setup the policy to be used by the system.
|
||||||
|
|
||||||
The input pointer must be one of those returned by get_avaiable_policies().
|
|
||||||
*/
|
*/
|
||||||
virtual void set_policy(Policy*) = 0;
|
virtual void set_policy(Policy*) = 0;
|
||||||
|
|
||||||
|
@ -137,6 +138,8 @@ namespace sgpem
|
||||||
*/
|
*/
|
||||||
virtual Policy* get_policy() = 0;
|
virtual Policy* get_policy() = 0;
|
||||||
|
|
||||||
|
virtual History& get_history() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Small kludge to avoid the need for declaration of ConcreteSimulation
|
* Small kludge to avoid the need for declaration of ConcreteSimulation
|
||||||
* by the calling code of Simulation::get_instance()
|
* by the calling code of Simulation::get_instance()
|
||||||
|
|
|
@ -23,11 +23,11 @@
|
||||||
#include "backend/policy_manager.hh"
|
#include "backend/policy_manager.hh"
|
||||||
#include "backend/policy_parameters.hh"
|
#include "backend/policy_parameters.hh"
|
||||||
#include "backend/history.hh"
|
#include "backend/history.hh"
|
||||||
#include "backend/dynamic_process.hh"
|
#include "backend/static_process.hh"
|
||||||
#include "backend/dynamic_resource.hh"
|
#include "backend/static_resource.hh"
|
||||||
#include "backend/dynamic_thread.hh"
|
#include "backend/static_thread.hh"
|
||||||
#include "backend/dynamic_request.hh"
|
#include "backend/static_request.hh"
|
||||||
#include "backend/dynamic_sub_request.hh"
|
#include "backend/static_sub_request.hh"
|
||||||
#include "backend/concrete_history.hh"
|
#include "backend/concrete_history.hh"
|
||||||
|
|
||||||
#include "text_simulation.hh"
|
#include "text_simulation.hh"
|
||||||
|
@ -125,15 +125,14 @@ TextSimulation::check_arguments_num(const Tokens& arguments, unsigned int num)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename Container>
|
||||||
void
|
void
|
||||||
TextSimulation::show(const vector<T*>& entities)
|
TextSimulation::show(const Container& entities)
|
||||||
{
|
{
|
||||||
ostringstream oss;
|
|
||||||
|
|
||||||
for(unsigned int i = 0; i < entities.size(); ++i)
|
for(unsigned int i = 0; i < entities.size(); ++i)
|
||||||
{
|
{
|
||||||
oss << i + 1 << ". " << entities[i]->get_core().get_name() << endl;
|
ostringstream oss;
|
||||||
|
oss << i + 1 << ". " << entities[i]->get_name() << endl;
|
||||||
p_stdout(oss.str());
|
p_stdout(oss.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,29 +142,45 @@ namespace sgpem
|
||||||
{
|
{
|
||||||
template <>
|
template <>
|
||||||
void
|
void
|
||||||
TextSimulation::show<DynamicRequest>(const vector<DynamicRequest*>& entities)
|
TextSimulation::show<vector<Request*> >(const vector<Request*>& entities)
|
||||||
{
|
{
|
||||||
ostringstream oss;
|
|
||||||
|
|
||||||
for(unsigned int i = 0; i < entities.size(); ++i)
|
for(unsigned int i = 0; i < entities.size(); ++i)
|
||||||
{
|
{
|
||||||
oss << i + 1 << ". instant: " << entities[i]->get_core().get_instant() << endl;
|
ostringstream oss;
|
||||||
|
oss << i + 1 << ". instant: " << entities[i]->get_instant() << endl;
|
||||||
p_stdout(oss.str());
|
p_stdout(oss.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void
|
void
|
||||||
TextSimulation::show<DynamicSubRequest>(const vector<DynamicSubRequest*>& entities)
|
TextSimulation::show<vector<SubRequest*> >(const vector<SubRequest*>& entities)
|
||||||
{
|
{
|
||||||
ostringstream oss;
|
|
||||||
|
|
||||||
for(unsigned int i = 0; i < entities.size(); ++i)
|
for(unsigned int i = 0; i < entities.size(); ++i)
|
||||||
{
|
{
|
||||||
oss << i + 1 << ". resource: " << entities[i]->get_core().get_resource_key() << endl;
|
ostringstream oss;
|
||||||
|
|
||||||
|
oss << i + 1 << ". resource: " << entities[i]->get_resource_key() << endl;
|
||||||
p_stdout(oss.str());
|
p_stdout(oss.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
void
|
||||||
|
TextSimulation::show<map<int, Resource*> >(const map<int, Resource*>& entities)
|
||||||
|
{
|
||||||
|
typedef map<int, Resource*>::const_iterator ResourceIt;
|
||||||
|
|
||||||
|
for(ResourceIt it = entities.begin(); it != entities.end(); ++it)
|
||||||
|
{
|
||||||
|
ostringstream oss;
|
||||||
|
|
||||||
|
oss << it->first << ". " << it->second->get_name();
|
||||||
|
oss << "[" << it->second->get_places() << "]" << endl;
|
||||||
|
p_stdout(oss.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -210,7 +225,7 @@ TextSimulation::get_parameter(CommandParameter<T>& parameter)
|
||||||
}
|
}
|
||||||
catch(domain_error e)
|
catch(domain_error e)
|
||||||
{
|
{
|
||||||
p_stderr(_("\nERROR: Please provide a valid integer value"));
|
p_stderr(_("\nERROR: Please provide a valid numeric value"));
|
||||||
correct = false;
|
correct = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,21 +366,15 @@ TextSimulation::on_configure_cpu_policy(const Tokens& arguments)
|
||||||
{
|
{
|
||||||
check_arguments_num(arguments, 0);
|
check_arguments_num(arguments, 0);
|
||||||
|
|
||||||
// FIXME we should use the current policy to obtain parmaters, this code
|
Policy* policy = Simulation::get_instance().get_policy();
|
||||||
// is only for testing purposes
|
|
||||||
PolicyParameters parameters;
|
|
||||||
|
|
||||||
parameters.register_int("a", -50, 50, false, 10);
|
if(policy == NULL)
|
||||||
parameters.register_int("b", -2, INT_MAX, true);
|
{
|
||||||
parameters.register_int("c", INT_MIN, 2, true);
|
p_stderr(_("\nERROR: No policy actually selected for the simulation\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
parameters.register_float("d", -FLT_MAX, FLT_MAX, true);
|
PolicyParameters& parameters = policy->get_parameters();
|
||||||
parameters.register_float("e", -5.0f, 50.0f, false, 10);
|
|
||||||
parameters.register_float("f", -FLT_MAX, 2.0f, true);
|
|
||||||
|
|
||||||
parameters.register_string("g", false);
|
|
||||||
parameters.register_string("h", true);
|
|
||||||
parameters.register_string("g", true);
|
|
||||||
|
|
||||||
p_stdout(_("\nPlease provide a value for each attribute:"));
|
p_stdout(_("\nPlease provide a value for each attribute:"));
|
||||||
p_stdout(_("\nMandatory arguments are marked with an asterisk (*)\n"));
|
p_stdout(_("\nMandatory arguments are marked with an asterisk (*)\n"));
|
||||||
|
@ -722,9 +731,8 @@ TextSimulation::on_show_processes(const Tokens& arguments)
|
||||||
{
|
{
|
||||||
check_arguments_num(arguments, 0);
|
check_arguments_num(arguments, 0);
|
||||||
|
|
||||||
// FIXME need to get the true process array. i think it's
|
const Environment& env = Simulation::get_instance().get_history().get_environment_at(0);
|
||||||
// still not possible at the actual stage of development
|
const Environment::Processes& processes = env.get_processes();
|
||||||
vector<DynamicProcess*> processes;
|
|
||||||
|
|
||||||
show(processes);
|
show(processes);
|
||||||
}
|
}
|
||||||
|
@ -734,9 +742,8 @@ TextSimulation::on_show_resources(const Tokens& arguments)
|
||||||
{
|
{
|
||||||
check_arguments_num(arguments, 0);
|
check_arguments_num(arguments, 0);
|
||||||
|
|
||||||
// FIXME need to get the true resource array. i think it's
|
const Environment& env = Simulation::get_instance().get_history().get_environment_at(0);
|
||||||
// still not possible at the actual stage of development
|
const Environment::Resources& resources = env.get_resources();
|
||||||
vector<DynamicResource*> resources;
|
|
||||||
|
|
||||||
show(resources);
|
show(resources);
|
||||||
}
|
}
|
||||||
|
@ -749,15 +756,15 @@ TextSimulation::on_show_threads(const Tokens& arguments)
|
||||||
|
|
||||||
ustring process = arguments[0];
|
ustring process = arguments[0];
|
||||||
|
|
||||||
// FIXME need to get the true arrays. i think it's
|
const Environment& env = Simulation::get_instance().get_history().get_environment_at(0);
|
||||||
// still not possible at the actual stage of development
|
const Environment::Processes& processes = env.get_processes();
|
||||||
vector<DynamicProcess*> processes;
|
|
||||||
vector<DynamicThread*> threads;
|
vector<Thread*> threads;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int pid = string_to<int>(process) - 1;
|
int pid = string_to<int>(process) - 1;
|
||||||
threads = processes.at(pid)->get_dynamic_threads();
|
threads = processes.at(pid)->get_threads();
|
||||||
}
|
}
|
||||||
catch(domain_error e)
|
catch(domain_error e)
|
||||||
{
|
{
|
||||||
|
@ -783,18 +790,17 @@ TextSimulation::on_show_requests(const Tokens& arguments)
|
||||||
ustring process = arguments[0];
|
ustring process = arguments[0];
|
||||||
ustring thread = arguments[1];
|
ustring thread = arguments[1];
|
||||||
|
|
||||||
// FIXME need to get the true arrays. i think it's
|
const Environment& env = Simulation::get_instance().get_history().get_environment_at(0);
|
||||||
// still not possible at the actual stage of development
|
const Environment::Processes& processes = env.get_processes();
|
||||||
vector<DynamicProcess*> processes;
|
vector<Request*> requests;
|
||||||
vector<DynamicRequest*> requests;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int pid = string_to<int>(process) - 1;
|
int pid = string_to<int>(process) - 1;
|
||||||
int tid = string_to<int>(thread) - 1;
|
int tid = string_to<int>(thread) - 1;
|
||||||
|
|
||||||
vector<DynamicThread*> threads = processes.at(pid)->get_dynamic_threads();
|
vector<Thread*> threads = processes.at(pid)->get_threads();
|
||||||
requests = threads.at(tid)->get_dynamic_requests();
|
requests = threads.at(tid)->get_requests();
|
||||||
}
|
}
|
||||||
catch(domain_error e)
|
catch(domain_error e)
|
||||||
{
|
{
|
||||||
|
@ -820,10 +826,9 @@ TextSimulation::on_show_subrequests(const Tokens& arguments)
|
||||||
ustring thread = arguments[1];
|
ustring thread = arguments[1];
|
||||||
ustring request = arguments[2];
|
ustring request = arguments[2];
|
||||||
|
|
||||||
// FIXME need to get the true arrays. i think it's
|
const Environment& env = Simulation::get_instance().get_history().get_environment_at(0);
|
||||||
// still not possible at the actual stage of development
|
const Environment::Processes& processes = env.get_processes();
|
||||||
vector<DynamicProcess*> processes;
|
vector<SubRequest*> subrequests;
|
||||||
vector<DynamicSubRequest*> subrequests;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -831,9 +836,9 @@ TextSimulation::on_show_subrequests(const Tokens& arguments)
|
||||||
int tid = string_to<int>(thread) - 1;
|
int tid = string_to<int>(thread) - 1;
|
||||||
int rid = string_to<int>(request) - 1;
|
int rid = string_to<int>(request) - 1;
|
||||||
|
|
||||||
vector<DynamicThread*> threads = processes.at(pid)->get_dynamic_threads();
|
vector<Thread*> threads = processes.at(pid)->get_threads();
|
||||||
vector<DynamicRequest*> requests = threads.at(tid)->get_dynamic_requests();
|
vector<Request*> requests = threads.at(tid)->get_requests();
|
||||||
subrequests = requests.at(rid)->get_dynamic_subrequests();
|
subrequests = requests.at(rid)->get_subrequests();
|
||||||
}
|
}
|
||||||
catch(domain_error e)
|
catch(domain_error e)
|
||||||
{
|
{
|
||||||
|
@ -895,6 +900,9 @@ TextSimulation::on_add(const Tokens& arguments)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Simulation::get_instance().get_state() != Simulation::state_stopped)
|
||||||
|
p_stderr(_("WARNING: Simulation is not stopped, it will be automatically stopped"));
|
||||||
|
|
||||||
//make a local copy which we'll probably modify
|
//make a local copy which we'll probably modify
|
||||||
Tokens args = arguments;
|
Tokens args = arguments;
|
||||||
|
|
||||||
|
@ -929,8 +937,7 @@ TextSimulation::on_add_process(const Tokens& arguments)
|
||||||
get_parameter(arrival_time);
|
get_parameter(arrival_time);
|
||||||
get_parameter(base_priority);
|
get_parameter(base_priority);
|
||||||
|
|
||||||
// FIXME: need to use the true history, not this stub
|
History& h = Simulation::get_instance().get_history();
|
||||||
ConcreteHistory h;
|
|
||||||
|
|
||||||
h.add_process(name.value, arrival_time.value, base_priority.value);
|
h.add_process(name.value, arrival_time.value, base_priority.value);
|
||||||
}
|
}
|
||||||
|
@ -941,7 +948,6 @@ TextSimulation::on_add_resource(const Tokens& arguments)
|
||||||
check_arguments_num(arguments, 0);
|
check_arguments_num(arguments, 0);
|
||||||
|
|
||||||
CommandParameter<ustring> name(_("name"), "", "", false, "");
|
CommandParameter<ustring> name(_("name"), "", "", false, "");
|
||||||
// FIXME need to further specialize string_to and get_parameter for bool
|
|
||||||
CommandParameter<bool> preemptable(_("pre-emptable?"), false, false, false, false);
|
CommandParameter<bool> preemptable(_("pre-emptable?"), false, false, false, false);
|
||||||
CommandParameter<int> places(_("places"), 0, INT_MAX, false, 1);
|
CommandParameter<int> places(_("places"), 0, INT_MAX, false, 1);
|
||||||
CommandParameter<int> availability(_("availability"), 0, INT_MAX, false, 0);
|
CommandParameter<int> availability(_("availability"), 0, INT_MAX, false, 0);
|
||||||
|
@ -951,8 +957,7 @@ TextSimulation::on_add_resource(const Tokens& arguments)
|
||||||
get_parameter(places);
|
get_parameter(places);
|
||||||
get_parameter(availability);
|
get_parameter(availability);
|
||||||
|
|
||||||
// FIXME: need to use the true history, not this stub
|
History& h = Simulation::get_instance().get_history();
|
||||||
ConcreteHistory h;
|
|
||||||
|
|
||||||
h.add_resource(name.value, preemptable.value, places.value, availability.value);
|
h.add_resource(name.value, preemptable.value, places.value, availability.value);
|
||||||
}
|
}
|
||||||
|
@ -965,9 +970,10 @@ TextSimulation::on_add_thread(const Tokens& arguments)
|
||||||
|
|
||||||
ustring process = arguments[0];
|
ustring process = arguments[0];
|
||||||
|
|
||||||
vector<DynamicProcess*> processes;
|
const Environment& env = Simulation::get_instance().get_history().get_environment_at(0);
|
||||||
|
const Environment::Processes& processes = env.get_processes();
|
||||||
|
|
||||||
DynamicProcess* p;
|
Process* p;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -994,8 +1000,7 @@ TextSimulation::on_add_thread(const Tokens& arguments)
|
||||||
get_parameter(arrival_time);
|
get_parameter(arrival_time);
|
||||||
get_parameter(base_priority);
|
get_parameter(base_priority);
|
||||||
|
|
||||||
// FIXME: need to use the true history, not this stub
|
History& h = Simulation::get_instance().get_history();
|
||||||
ConcreteHistory h;
|
|
||||||
|
|
||||||
h.add_thread(name.value, *p, cpu_time.value, arrival_time.value,
|
h.add_thread(name.value, *p, cpu_time.value, arrival_time.value,
|
||||||
base_priority.value);
|
base_priority.value);
|
||||||
|
@ -1010,17 +1015,17 @@ TextSimulation::on_add_request(const Tokens& arguments)
|
||||||
ustring process = arguments[0];
|
ustring process = arguments[0];
|
||||||
ustring thread = arguments[1];
|
ustring thread = arguments[1];
|
||||||
|
|
||||||
// FIXME need to get the true arrays. i think it's
|
const Environment& env = Simulation::get_instance().get_history().get_environment_at(0);
|
||||||
// still not possible at the actual stage of development
|
const Environment::Processes& processes = env.get_processes();
|
||||||
vector<DynamicProcess*> processes;
|
|
||||||
DynamicThread* t;
|
Thread* t;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int pid = string_to<int>(process) - 1;
|
int pid = string_to<int>(process) - 1;
|
||||||
int tid = string_to<int>(thread) - 1;
|
int tid = string_to<int>(thread) - 1;
|
||||||
|
|
||||||
vector<DynamicThread*> threads = processes.at(pid)->get_dynamic_threads();
|
vector<Thread*> threads = processes.at(pid)->get_threads();
|
||||||
t = threads.at(tid);
|
t = threads.at(tid);
|
||||||
}
|
}
|
||||||
catch(domain_error e)
|
catch(domain_error e)
|
||||||
|
@ -1038,8 +1043,7 @@ TextSimulation::on_add_request(const Tokens& arguments)
|
||||||
|
|
||||||
get_parameter(instant);
|
get_parameter(instant);
|
||||||
|
|
||||||
// FIXME: need to use the true history, not this stub
|
History& h = Simulation::get_instance().get_history();
|
||||||
ConcreteHistory h;
|
|
||||||
|
|
||||||
h.add_request(*t, instant.value);
|
h.add_request(*t, instant.value);
|
||||||
}
|
}
|
||||||
|
@ -1054,10 +1058,10 @@ TextSimulation::on_add_subrequest(const Tokens& arguments)
|
||||||
ustring thread = arguments[1];
|
ustring thread = arguments[1];
|
||||||
ustring request = arguments[2];
|
ustring request = arguments[2];
|
||||||
|
|
||||||
// FIXME need to get the true arrays. i think it's
|
const Environment& env = Simulation::get_instance().get_history().get_environment_at(0);
|
||||||
// still not possible at the actual stage of development
|
const Environment::Processes& processes = env.get_processes();
|
||||||
vector<DynamicProcess*> processes;
|
|
||||||
DynamicRequest* r;
|
Request* r;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1065,8 +1069,8 @@ TextSimulation::on_add_subrequest(const Tokens& arguments)
|
||||||
int tid = string_to<int>(thread) - 1;
|
int tid = string_to<int>(thread) - 1;
|
||||||
int rid = string_to<int>(request) - 1;
|
int rid = string_to<int>(request) - 1;
|
||||||
|
|
||||||
vector<DynamicThread*> threads = processes.at(pid)->get_dynamic_threads();
|
vector<Thread*> threads = processes.at(pid)->get_threads();
|
||||||
vector<DynamicRequest*> requests = threads.at(tid)->get_dynamic_requests();
|
vector<Request*> requests = threads.at(tid)->get_requests();
|
||||||
r = requests.at(rid);
|
r = requests.at(rid);
|
||||||
}
|
}
|
||||||
catch(domain_error e)
|
catch(domain_error e)
|
||||||
|
@ -1080,16 +1084,13 @@ TextSimulation::on_add_subrequest(const Tokens& arguments)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME here we are in troubles, we ask the resource key, but the user can't know it.
|
|
||||||
// How we may obtain it? I think it'll be better making it a member of DynamicResource
|
|
||||||
CommandParameter<int> resource_key(_("resource key"), 0, INT_MAX, true, 0);
|
CommandParameter<int> resource_key(_("resource key"), 0, INT_MAX, true, 0);
|
||||||
CommandParameter<int> duration(_("duration"), 0, INT_MAX, true, 0);
|
CommandParameter<int> duration(_("duration"), 0, INT_MAX, true, 0);
|
||||||
CommandParameter<int> places(_("places"), 0, INT_MAX, false, 1);
|
CommandParameter<int> places(_("places"), 0, INT_MAX, false, 1);
|
||||||
|
|
||||||
// FIXME: need to use the true history, not this stub
|
History& h = Simulation::get_instance().get_history();
|
||||||
ConcreteHistory h;
|
|
||||||
|
|
||||||
h.add_subrequest(*r, resource_key.value /*resource key*/, duration.value, places.value);
|
h.add_subrequest(*r, resource_key.value, duration.value, places.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1102,6 +1103,9 @@ TextSimulation::on_remove(const Tokens& arguments)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Simulation::get_instance().get_state() != Simulation::state_stopped)
|
||||||
|
p_stderr(_("WARNING: Simulation is not stopped, it will be automatically stopped"));
|
||||||
|
|
||||||
//make a local copy which we'll probably modify
|
//make a local copy which we'll probably modify
|
||||||
Tokens args = arguments;
|
Tokens args = arguments;
|
||||||
|
|
||||||
|
@ -1131,11 +1135,10 @@ TextSimulation::on_remove_process(const Tokens& arguments)
|
||||||
|
|
||||||
ustring process = arguments[0];
|
ustring process = arguments[0];
|
||||||
|
|
||||||
// FIXME need to get the true arrays. i think it's
|
const Environment& env = Simulation::get_instance().get_history().get_environment_at(0);
|
||||||
// still not possible at the actual stage of development
|
const Environment::Processes& processes = env.get_processes();
|
||||||
vector<DynamicProcess*> processes;
|
|
||||||
|
|
||||||
DynamicProcess* p;
|
Process* p;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1152,8 +1155,7 @@ TextSimulation::on_remove_process(const Tokens& arguments)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: need to use the true history, not this stub
|
History& h = Simulation::get_instance().get_history();
|
||||||
ConcreteHistory h;
|
|
||||||
h.remove(*p);
|
h.remove(*p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1165,16 +1167,14 @@ TextSimulation::on_remove_resource(const Tokens& arguments)
|
||||||
|
|
||||||
ustring resource = arguments[0];
|
ustring resource = arguments[0];
|
||||||
|
|
||||||
// FIXME need to get the true arrays. i think it's
|
const Environment& env = Simulation::get_instance().get_history().get_environment_at(0);
|
||||||
// still not possible at the actual stage of development
|
const Environment::Processes& processes = env.get_processes();
|
||||||
vector<DynamicProcess*> resources;
|
|
||||||
|
|
||||||
ConcreteHistory::resource_key_t rid;
|
ConcreteHistory::resource_key_t rid;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//FIXME this is WRONG
|
rid = string_to<int>(resource);
|
||||||
rid = string_to<int>(resource) - 1;
|
|
||||||
}
|
}
|
||||||
catch(domain_error e)
|
catch(domain_error e)
|
||||||
{
|
{
|
||||||
|
@ -1187,8 +1187,7 @@ TextSimulation::on_remove_resource(const Tokens& arguments)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: need to use the true history, not this stub
|
History& h = Simulation::get_instance().get_history();
|
||||||
ConcreteHistory h;
|
|
||||||
h.remove(rid);
|
h.remove(rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1201,17 +1200,17 @@ TextSimulation::on_remove_thread(const Tokens& arguments)
|
||||||
ustring process = arguments[0];
|
ustring process = arguments[0];
|
||||||
ustring thread = arguments[1];
|
ustring thread = arguments[1];
|
||||||
|
|
||||||
// FIXME need to get the true arrays. i think it's
|
const Environment& env = Simulation::get_instance().get_history().get_environment_at(0);
|
||||||
// still not possible at the actual stage of development
|
const Environment::Processes& processes = env.get_processes();
|
||||||
vector<DynamicProcess*> processes;
|
|
||||||
DynamicThread* t;
|
Thread* t;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int pid = string_to<int>(process) - 1;
|
int pid = string_to<int>(process) - 1;
|
||||||
int tid = string_to<int>(thread) - 1;
|
int tid = string_to<int>(thread) - 1;
|
||||||
|
|
||||||
vector<DynamicThread*> threads = processes.at(pid)->get_dynamic_threads();
|
vector<Thread*> threads = processes.at(pid)->get_threads();
|
||||||
t = threads.at(tid);
|
t = threads.at(tid);
|
||||||
}
|
}
|
||||||
catch(domain_error e)
|
catch(domain_error e)
|
||||||
|
@ -1225,8 +1224,7 @@ TextSimulation::on_remove_thread(const Tokens& arguments)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: need to use the true history, not this stub
|
History& h = Simulation::get_instance().get_history();
|
||||||
ConcreteHistory h;
|
|
||||||
h.remove(*t);
|
h.remove(*t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1240,10 +1238,10 @@ TextSimulation::on_remove_request(const Tokens& arguments)
|
||||||
ustring thread = arguments[1];
|
ustring thread = arguments[1];
|
||||||
ustring request = arguments[2];
|
ustring request = arguments[2];
|
||||||
|
|
||||||
// FIXME need to get the true arrays. i think it's
|
const Environment& env = Simulation::get_instance().get_history().get_environment_at(0);
|
||||||
// still not possible at the actual stage of development
|
const Environment::Processes& processes = env.get_processes();
|
||||||
vector<DynamicProcess*> processes;
|
|
||||||
DynamicRequest* r;
|
Request* r;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1251,8 +1249,8 @@ TextSimulation::on_remove_request(const Tokens& arguments)
|
||||||
int tid = string_to<int>(thread) - 1;
|
int tid = string_to<int>(thread) - 1;
|
||||||
int rid = string_to<int>(request) - 1;
|
int rid = string_to<int>(request) - 1;
|
||||||
|
|
||||||
vector<DynamicThread*> threads = processes.at(pid)->get_dynamic_threads();
|
vector<Thread*> threads = processes.at(pid)->get_threads();
|
||||||
vector<DynamicRequest*> requests = threads.at(tid)->get_dynamic_requests();
|
vector<Request*> requests = threads.at(tid)->get_requests();
|
||||||
r = requests.at(rid);
|
r = requests.at(rid);
|
||||||
}
|
}
|
||||||
catch(domain_error e)
|
catch(domain_error e)
|
||||||
|
@ -1266,7 +1264,7 @@ TextSimulation::on_remove_request(const Tokens& arguments)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConcreteHistory h;
|
History& h = Simulation::get_instance().get_history();
|
||||||
h.remove(*r);
|
h.remove(*r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1281,10 +1279,10 @@ TextSimulation::on_remove_subrequest(const Tokens& arguments)
|
||||||
ustring request = arguments[2];
|
ustring request = arguments[2];
|
||||||
ustring subrequest = arguments[3];
|
ustring subrequest = arguments[3];
|
||||||
|
|
||||||
// FIXME need to get the true arrays. i think it's
|
const Environment& env = Simulation::get_instance().get_history().get_environment_at(0);
|
||||||
// still not possible at the actual stage of development
|
const Environment::Processes& processes = env.get_processes();
|
||||||
vector<DynamicProcess*> processes;
|
|
||||||
DynamicSubRequest* r;
|
SubRequest* r;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1293,9 +1291,9 @@ TextSimulation::on_remove_subrequest(const Tokens& arguments)
|
||||||
int rid = string_to<int>(request) - 1;
|
int rid = string_to<int>(request) - 1;
|
||||||
int srid = string_to<int>(subrequest) - 1;
|
int srid = string_to<int>(subrequest) - 1;
|
||||||
|
|
||||||
vector<DynamicThread*> threads = processes.at(pid)->get_dynamic_threads();
|
vector<Thread*> threads = processes.at(pid)->get_threads();
|
||||||
vector<DynamicRequest*> requests = threads.at(tid)->get_dynamic_requests();
|
vector<Request*> requests = threads.at(tid)->get_requests();
|
||||||
vector<DynamicSubRequest*> subrequests = requests.at(rid)->get_dynamic_subrequests();
|
vector<SubRequest*> subrequests = requests.at(rid)->get_subrequests();
|
||||||
r = subrequests.at(srid);
|
r = subrequests.at(srid);
|
||||||
}
|
}
|
||||||
catch(domain_error e)
|
catch(domain_error e)
|
||||||
|
@ -1309,9 +1307,7 @@ TextSimulation::on_remove_subrequest(const Tokens& arguments)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: need to use the true history, not this stub
|
History& h = Simulation::get_instance().get_history();
|
||||||
ConcreteHistory h;
|
|
||||||
|
|
||||||
h.remove(*r);
|
h.remove(*r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,8 +128,8 @@ namespace sgpem
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool check_arguments_num(const Tokens& arguments, unsigned int num);
|
bool check_arguments_num(const Tokens& arguments, unsigned int num);
|
||||||
template <typename T>
|
template <typename Container>
|
||||||
void show(const std::vector<T*>& entities);
|
void show(const Container& entities);
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void get_parameter(CommandParameter<T>& parameter);
|
void get_parameter(CommandParameter<T>& parameter);
|
||||||
void on_run(const Tokens& arguments);
|
void on_run(const Tokens& arguments);
|
||||||
|
|
Loading…
Reference in New Issue