- Pretty-indenting code

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@674 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-06-29 08:44:30 +00:00
parent 7aecc910ba
commit 6b27a8461b
94 changed files with 3073 additions and 3066 deletions

11
config/indenter Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
#find . -name "*.cc" -or -name "*.hh" -or -name "*.tcc" | \
# xargs indent -v -sc -psl -bls -bad -bap -bbb -nsob \
# -bli0 -cli0 -cbi0 -npcs -cs -nsaf -nsai -nsaw \
# -nprs -i2 -lp -ppi2 -l80 -nbbo -hnl -ss -di8 -nbc
find . -name "*.cc" -or -name "*.hh" -or -name "*.tcc" | \
xargs astyle --style=ansi -s2 -b -N -L -p -O -V \
--mode=c

View File

@ -33,24 +33,25 @@
#include "config.h" #include "config.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C"
{
#endif #endif
#define SG_CONSTRUCTOR __attribute__ ((constructor)) #define SG_CONSTRUCTOR __attribute__ ((constructor))
#define SG_DESTRUCTOR __attribute__ ((destructor)) #define SG_DESTRUCTOR __attribute__ ((destructor))
#define _libpyloader_LTX__global_pm (_global_pm); #define _libpyloader_LTX__global_pm (_global_pm);
PolicyManager* _global_pm = NULL; PolicyManager* _global_pm = NULL;
void SG_DLLEXPORT SG_CONSTRUCTOR hook_ctor(void) void SG_DLLEXPORT SG_CONSTRUCTOR hook_ctor(void)
{ {
_global_pm = PythonPolicyManager::get_instance(); _global_pm = PythonPolicyManager::get_instance();
} }
void SG_DLLEXPORT SG_DESTRUCTOR hook_dtor(void) void SG_DLLEXPORT SG_DESTRUCTOR hook_dtor(void)
{ {
delete _global_pm; delete _global_pm;
} }
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -39,28 +39,33 @@
// FIXME: Eeeeh? Why does this work without explicit namespace resolving? // FIXME: Eeeeh? Why does this work without explicit namespace resolving?
// Is there some using declaration in included HEADERS?? Aaaaagh! // Is there some using declaration in included HEADERS?? Aaaaagh!
class TestPythonPolicyManager : public PythonPolicyManager { class TestPythonPolicyManager : public PythonPolicyManager
{
public: public:
void test_init(const char* policy_name) { void test_init(const char* policy_name)
{
init(); init();
_python_policy = new PythonPolicy(policy_name); _python_policy = new PythonPolicy(policy_name);
} }
Policy& get_policy() { Policy& get_policy()
{
return *_python_policy; return *_python_policy;
} }
}; };
int int
main(int argc, char** argv) { main(int argc, char** argv)
{
using namespace sgpem; using namespace sgpem;
using namespace std; using namespace std;
int successes = 0; int successes = 0;
if(argc != 2) { if(argc != 2)
{
std::cout << "[EE] Usage:\n\t" << argv[0] << std::cout << "[EE] Usage:\n\t" << argv[0] <<
" path/to/uninstalled/policies" << std::endl; " path/to/uninstalled/policies" << std::endl;
exit(-1); exit(-1);

View File

@ -29,7 +29,8 @@
therein. See "info libtool": "dlopened modules" therein. See "info libtool": "dlopened modules"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C"
{
#endif #endif
#include "config.h" #include "config.h"
@ -37,13 +38,11 @@ extern "C" {
#define SG_CONSTRUCTOR __attribute__ ((constructor)) #define SG_CONSTRUCTOR __attribute__ ((constructor))
#define SG_DESTRUCTOR __attribute__ ((destructor)) #define SG_DESTRUCTOR __attribute__ ((destructor))
void SG_DLLEXPORT SG_CONSTRUCTOR hook_ctor(void) void SG_DLLEXPORT SG_CONSTRUCTOR hook_ctor(void)
{ {}
}
void SG_DLLEXPORT SG_DESTRUCTOR hook_dtor(void) void SG_DLLEXPORT SG_DESTRUCTOR hook_dtor(void)
{ {}
}
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -30,8 +30,7 @@ using std::vector;
DynamicProcess::DynamicProcess(StaticProcess* core) : DynamicProcess::DynamicProcess(StaticProcess* core) :
DynamicSchedulable(*core) DynamicSchedulable(*core)
{ {}
}
DynamicProcess::DynamicProcess(const DynamicProcess &other) : DynamicProcess::DynamicProcess(const DynamicProcess &other) :
Schedulable(), DynamicSchedulable(other), Process() Schedulable(), DynamicSchedulable(other), Process()
@ -85,7 +84,8 @@ DynamicProcess::get_state() const
// TODO Is this OK? Must be tested... // TODO Is this OK? Must be tested...
switch(thread_state) { switch(thread_state)
{
case state_running: // (a) case state_running: // (a)
return state_running; return state_running;
case state_ready: // (b) case state_ready: // (b)

View File

@ -27,8 +27,7 @@ using namespace sgpem;
DynamicResource::DynamicResource(StaticResource *core) : DynamicResource::DynamicResource(StaticResource *core) :
_static_resource(core) _static_resource(core)
{ {}
}
Glib::ustring Glib::ustring
DynamicResource::get_name() const DynamicResource::get_name() const

View File

@ -29,8 +29,7 @@ DynamicSchedulable::DynamicSchedulable(StaticSchedulable& obj) :
_time_left(obj.get_total_cpu_time()), _ref(&obj), _last_acquisition(-1), _time_left(obj.get_total_cpu_time()), _ref(&obj), _last_acquisition(-1),
_last_release(-1), _priority_push(0), _last(-1), _last_release(-1), _priority_push(0), _last(-1),
_my_state(state_future) _my_state(state_future)
{ {}
}
bool bool
DynamicSchedulable::operator==(const DynamicSchedulable& dx) const DynamicSchedulable::operator==(const DynamicSchedulable& dx) const

View File

@ -112,8 +112,7 @@ namespace sgpem
void set_state(state s); void set_state(state s);
void serialize(SerializeVisitor& translator) const void serialize(SerializeVisitor& translator) const
{ {}
}
/** \brief Returns a pointer to the schedulable object /** \brief Returns a pointer to the schedulable object
* *

View File

@ -31,8 +31,7 @@ using std::vector;
DynamicThread::DynamicThread(StaticThread* core, DynamicProcess* parent) : DynamicThread::DynamicThread(StaticThread* core, DynamicProcess* parent) :
DynamicSchedulable(*core), _state(state_future), _parent(parent) DynamicSchedulable(*core), _state(state_future), _parent(parent)
{ {}
}
DynamicThread::DynamicThread(const DynamicThread &other) : DynamicThread::DynamicThread(const DynamicThread &other) :
Schedulable(), DynamicSchedulable(other), Thread() Schedulable(), DynamicSchedulable(other), Thread()

View File

@ -29,13 +29,15 @@
// Do not include complete template definition here: // Do not include complete template definition here:
#include "singleton.hh" #include "singleton.hh"
namespace sgpem { namespace sgpem
{
class GlobalPreferences; class GlobalPreferences;
} }
#include "config.h" #include "config.h"
namespace sgpem { namespace sgpem
{
class SG_DLLEXPORT GlobalPreferences : public Singleton<GlobalPreferences> class SG_DLLEXPORT GlobalPreferences : public Singleton<GlobalPreferences>
{ {
friend class Singleton<GlobalPreferences>; friend class Singleton<GlobalPreferences>;

View File

@ -42,7 +42,8 @@ template class SG_DLLEXPORT smart_ptr<DynamicSchedulable>;
of the simulation which must begin at instant -1 and live for 1 instant. of the simulation which must begin at instant -1 and live for 1 instant.
*/ */
History::History() //private constructor. History::History() //private constructor.
:_total_time_elapsed(-1) :
_total_time_elapsed(-1)
{} {}
@ -78,7 +79,7 @@ History::get_simulation_status_at(int time) const
return smart_ptr<SchedulableQueue>(NULL); return smart_ptr<SchedulableQueue>(NULL);
int trascorso = -1; int trascorso = -1;
for(vector<Slice>::const_iterator i=_slices.begin(); i < _slices.end(); i++) for(vector<Slice>::const_iterator i = _slices.begin(); i < _slices.end(); i++)
if (time <= trascorso + i->get_duration()) //FOUND!! if (time <= trascorso + i->get_duration()) //FOUND!!
return smart_ptr<SchedulableQueue>(new SchedulableQueue(*i->get_simulation_status())); return smart_ptr<SchedulableQueue>(new SchedulableQueue(*i->get_simulation_status()));
else //Go on... else //Go on...
@ -113,7 +114,7 @@ History::enqueue_slice(const SchedulableQueue& status)
Slice& last = _slices[_slices.size()-1]; Slice& last = _slices[_slices.size()-1];
if (last.get_simulation_status()->has_same_objects(status)) //increments the duration by ONE unit if (last.get_simulation_status()->has_same_objects(status)) //increments the duration by ONE unit
{ {
last.set_duration(last.get_duration()+1); last.set_duration(last.get_duration() + 1);
} }
else //insert a new slice CONTIGUOUS to the last one else //insert a new slice CONTIGUOUS to the last one
{ {
@ -140,7 +141,7 @@ History::truncate_at(int instant)
else else
{ {
//replaces the current vector with the "trimmed" one. //replaces the current vector with the "trimmed" one.
_slices = vector<Slice>(_slices.begin(),i); _slices = vector<Slice>(_slices.begin(), i);
_total_time_elapsed = instant; _total_time_elapsed = instant;
break; break;
} }

View File

@ -24,8 +24,7 @@ using namespace sgpem;
ObservedSubject::~ObservedSubject() ObservedSubject::~ObservedSubject()
{ {}
}
/** /**
Calls update() in each Observer Calls update() in each Observer

View File

@ -57,7 +57,8 @@ namespace sgpem
private: private:
SG_DLLLOCAL Plugin(); SG_DLLLOCAL Plugin();
}; //~ class Plugin }
; //~ class Plugin
} //~ namespace sgpem } //~ namespace sgpem

View File

@ -107,8 +107,7 @@ PoliciesGatekeeper::activate_policy(History *history, Policy* policy)
} }
PoliciesGatekeeper::PoliciesGatekeeper() PoliciesGatekeeper::PoliciesGatekeeper()
{ {}
}
void void
PoliciesGatekeeper::deactivate_policies(PolicyManager* manager) PoliciesGatekeeper::deactivate_policies(PolicyManager* manager)

View File

@ -24,8 +24,7 @@ using namespace sgpem;
using namespace memory; using namespace memory;
Policy::~Policy() Policy::~Policy()
{ {}
}
int int
Policy::get_id() const Policy::get_id() const

View File

@ -28,7 +28,7 @@ using Glib::ustring;
If there is a parameter with the same name and type it will be overwritten. If there is a parameter with the same name and type it will be overwritten.
*/ */
void void
PolicyParameters::register_int(Glib::ustring name,const int& lower_bound, const int& upper_bound, const bool& required, const int& default_value) PolicyParameters::register_int(Glib::ustring name, const int& lower_bound, const int& upper_bound, const bool& required, const int& default_value)
{ {
//there is a parameter with the same name!! //there is a parameter with the same name!!
map<ustring, Parameter<int> >::iterator i = int_map.find(name); map<ustring, Parameter<int> >::iterator i = int_map.find(name);
@ -45,7 +45,7 @@ PolicyParameters::register_int(Glib::ustring name,const int& lower_bound, const
If there is a parameter with the same name and type it will be overwritten. If there is a parameter with the same name and type it will be overwritten.
*/ */
void void
PolicyParameters::register_float(Glib::ustring name,const float& lower_bound, const float& upper_bound, const bool& required, const float& default_value) PolicyParameters::register_float(Glib::ustring name, const float& lower_bound, const float& upper_bound, const bool& required, const float& default_value)
{ {
//there is a parameter with the same name!! //there is a parameter with the same name!!
map<ustring, Parameter<float> >::iterator i = float_map.find(name); map<ustring, Parameter<float> >::iterator i = float_map.find(name);
@ -97,7 +97,7 @@ PolicyParameters::get_registered_int_parameters() const
Retruns a copy of the map containing all registered float parameters. Retruns a copy of the map containing all registered float parameters.
*/ */
map<ustring, PolicyParameters::Parameter<float> > map<ustring, PolicyParameters::Parameter<float> >
PolicyParameters::get_registered_float_parameters() const PolicyParameters::get_registered_float_parameters() const
{ {
return float_map; return float_map;
} }

View File

@ -33,8 +33,7 @@ namespace sgpem
class PolicyParametersException : public std::runtime_error class PolicyParametersException : public std::runtime_error
{ {
public: public:
PolicyParametersException(char* msg): std::runtime_error(msg) {} PolicyParametersException(char* msg): std::runtime_error(msg) {}};
};
class PolicyParameters; class PolicyParameters;
@ -66,7 +65,7 @@ namespace sgpem
\param required Denotes if this parameter is required by the policy. \param required Denotes if this parameter is required by the policy.
\param default_value The initial value of this parameter. (If not specified it's set to 0). \param default_value The initial value of this parameter. (If not specified it's set to 0).
*/ */
void register_int(Glib::ustring name,const int& lower_bound, const int& upper_bound, const bool& required, const int& default_value = 0); void register_int(Glib::ustring name, const int& lower_bound, const int& upper_bound, const bool& required, const int& default_value = 0);
/**\brief Registers a FLOAT parameter. /**\brief Registers a FLOAT parameter.
@ -80,7 +79,7 @@ namespace sgpem
\param required Denotes if this parameter is required by the policy. \param required Denotes if this parameter is required by the policy.
\param default_value The initial value of this parameter. (If not specified it's set to 0.0f). \param default_value The initial value of this parameter. (If not specified it's set to 0.0f).
*/ */
void register_float(Glib::ustring name,const float& lower_bound, const float& upper_bound, const bool& required, const float& default_value = 0.0f); void register_float(Glib::ustring name, const float& lower_bound, const float& upper_bound, const bool& required, const float& default_value = 0.0f);
/**\brief Registers a STRING parameter. /**\brief Registers a STRING parameter.

View File

@ -23,6 +23,5 @@
using namespace sgpem; using namespace sgpem;
Process::~Process() Process::~Process()
{ {}
}

View File

@ -23,6 +23,5 @@
using namespace sgpem; using namespace sgpem;
Request::~Request() Request::~Request()
{ {}
}

View File

@ -23,6 +23,5 @@
using namespace sgpem; using namespace sgpem;
Resource::~Resource() Resource::~Resource()
{ {}
}

View File

@ -23,6 +23,5 @@
using namespace sgpem; using namespace sgpem;
Schedulable::~Schedulable() Schedulable::~Schedulable()
{ {}
}

View File

@ -41,11 +41,11 @@ namespace sgpem
*/ */
enum state enum state
{ {
state_running = 1<<0, state_running = 1 << 0,
state_ready = 1<<1, state_ready = 1 << 1,
state_blocked = 1<<2, state_blocked = 1 << 2,
state_future = 1<<3, state_future = 1 << 3,
state_terminated = 1<<4 state_terminated = 1 << 4
}; };
virtual ~Schedulable() = 0; virtual ~Schedulable() = 0;

View File

@ -27,8 +27,7 @@ using namespace std;
using namespace memory; using namespace memory;
SchedulableQueue::SchedulableQueue() SchedulableQueue::SchedulableQueue()
{ {}
}
DynamicSchedulable* DynamicSchedulable*
SchedulableQueue::top() SchedulableQueue::top()
@ -59,7 +58,7 @@ SchedulableQueue::get_item_at(const uint& where)
return NULL; return NULL;
list<DynamicSchedulable>::iterator i = _list.begin(); list<DynamicSchedulable>::iterator i = _list.begin();
for (uint f=0; f < where; f++) for (uint f = 0; f < where; f++)
i++; i++;
return &(*i); return &(*i);
} }
@ -71,7 +70,7 @@ SchedulableQueue::get_item_at(const uint& where) const
return NULL; return NULL;
list<DynamicSchedulable>::const_iterator i = _list.begin(); list<DynamicSchedulable>::const_iterator i = _list.begin();
for (uint f=0; f < where; f++) for (uint f = 0; f < where; f++)
i++; i++;
return &(*i); return &(*i);
} }
@ -127,9 +126,9 @@ SchedulableQueue::insert_at(const uint& which, const uint& where)
list<DynamicSchedulable>::iterator i_where = _list.begin(); list<DynamicSchedulable>::iterator i_where = _list.begin();
list<DynamicSchedulable>::iterator i_which = _list.begin(); list<DynamicSchedulable>::iterator i_which = _list.begin();
for (uint f=0; f < where; f++) for (uint f = 0; f < where; f++)
i_where++; i_where++;
for (uint f=0; f < which; f++) for (uint f = 0; f < which; f++)
i_which++; i_which++;
//save and pop WHICH //save and pop WHICH
@ -172,7 +171,7 @@ SchedulableQueue::has_same_objects(const SchedulableQueue& dx) const
return false; return false;
//check if dx has ALL and ONLY the elements holded by _list with no order importance //check if dx has ALL and ONLY the elements holded by _list with no order importance
for(list<DynamicSchedulable>::const_iterator f=_list.begin(); f != _list.end(); f++) for(list<DynamicSchedulable>::const_iterator f = _list.begin(); f != _list.end(); f++)
if (find(dx._list.begin(), dx._list.end(), *f) == dx._list.end()) //element NOT found!! if (find(dx._list.begin(), dx._list.end(), *f) == dx._list.end()) //element NOT found!!
return false; return false;
@ -202,13 +201,13 @@ SchedulableQueue::swap(unsigned int positionA, unsigned int positionB) throw()
list<DynamicSchedulable>::iterator i2 = _list.begin(); list<DynamicSchedulable>::iterator i2 = _list.begin();
//reach the first element; //reach the first element;
for (uint f=0; f < min; f++) for (uint f = 0; f < min; f++)
i1++; i1++;
DynamicSchedulable temp = *i1; DynamicSchedulable temp = *i1;
//reach the second element; //reach the second element;
i2 = i1; i2 = i1;
for (uint f=min; f < max; f++) for (uint f = min; f < max; f++)
i2++; i2++;
*i1 = *i2; *i1 = *i2;

View File

@ -63,13 +63,13 @@ namespace sgpem
void add_at_bottom(const DynamicSchedulable&); void add_at_bottom(const DynamicSchedulable&);
/** \brief Removes */ /** \brief Removes */
/** /**
Removes an element from the list. Returns a smart pointer a copy of it or to NULL if Removes an element from the list. Returns a smart pointer a copy of it or to NULL if
"position" is out of range. "position" is out of range.
Ex. remove(0); removes the top of the list Ex. remove(0); removes the top of the list
Ex. remove(size()-1) removes the bottom of the list Ex. remove(size()-1) removes the bottom of the list
*/ */
memory::smart_ptr<sgpem::DynamicSchedulable> remove(const unsigned int& position); memory::smart_ptr<sgpem::DynamicSchedulable> remove(const unsigned int& position);
bool insert_at(const unsigned int&, const unsigned int&); bool insert_at(const unsigned int&, const unsigned int&);

View File

@ -103,12 +103,12 @@ Scheduler::step_forward() throw(UserInterruptException)
_ready_queue.add_at_top(*running_ptr); _ready_queue.add_at_top(*running_ptr);
//adds the READY ones //adds the READY ones
for(uint rea=0; rea < initial->size(); rea++) for(uint rea = 0; rea < initial->size(); rea++)
if (initial->get_item_at(rea)->get_state() == DynamicSchedulable::state_ready) if (initial->get_item_at(rea)->get_state() == DynamicSchedulable::state_ready)
_ready_queue.add_at_bottom(*initial->get_item_at(rea)); _ready_queue.add_at_bottom(*initial->get_item_at(rea));
//adds each new ready schedulable and sorts the queue //adds each new ready schedulable and sorts the queue
for(uint i=0; i < initial->size(); i++) for(uint i = 0; i < initial->size(); i++)
if (initial->get_item_at(i)->get_state() == DynamicSchedulable::state_future if (initial->get_item_at(i)->get_state() == DynamicSchedulable::state_future
&& (int)initial->get_item_at(i)->get_schedulable()->get_arrival_time() == h.get_current_time()) && (int)initial->get_item_at(i)->get_schedulable()->get_arrival_time() == h.get_current_time())
{ {
@ -120,7 +120,7 @@ Scheduler::step_forward() throw(UserInterruptException)
//adds the NEW one //adds the NEW one
_ready_queue.add_at_bottom(*initial->get_item_at(i)); _ready_queue.add_at_bottom(*initial->get_item_at(i));
_ready_queue.get_item_at(_ready_queue.size()-1)->set_state(DynamicSchedulable::state_ready); _ready_queue.get_item_at(_ready_queue.size() - 1)->set_state(DynamicSchedulable::state_ready);
initial->get_item_at(i)->set_state(DynamicSchedulable::state_ready); initial->get_item_at(i)->set_state(DynamicSchedulable::state_ready);
// Sort the queue // Sort the queue
@ -139,12 +139,12 @@ Scheduler::step_forward() throw(UserInterruptException)
if (running_ptr && running_ptr->get_cpu_time_left() == 0) if (running_ptr && running_ptr->get_cpu_time_left() == 0)
{ {
//there is a running schedulable and it's terminated. Append at the bottom with the state TERMINATED //there is a running schedulable and it's terminated. Append at the bottom with the state TERMINATED
for(uint i=0; i < _ready_queue.size(); i++) for(uint i = 0; i < _ready_queue.size(); i++)
if (*_ready_queue.get_item_at(i) == *running_ptr) if (*_ready_queue.get_item_at(i) == *running_ptr)
{ {
_ready_queue.add_at_bottom(*_ready_queue.get_item_at(i)); _ready_queue.add_at_bottom(*_ready_queue.get_item_at(i));
_ready_queue.remove(i); _ready_queue.remove(i);
_ready_queue.get_item_at(_ready_queue.size()-1)->set_state(DynamicSchedulable::state_terminated); _ready_queue.get_item_at(_ready_queue.size() - 1)->set_state(DynamicSchedulable::state_terminated);
break; break;
} }
//cout << "\nTERMINATO!!"; //cout << "\nTERMINATO!!";

View File

@ -25,8 +25,7 @@ using namespace std;
Slice::Slice(const int& start, const int& duration, const SchedulableQueue& status) Slice::Slice(const int& start, const int& duration, const SchedulableQueue& status)
: _ref(status), _started_at(start), _duration(duration) : _ref(status), _started_at(start), _duration(duration)
{ {}
}
const SchedulableQueue* const SchedulableQueue*
Slice::get_simulation_status() const Slice::get_simulation_status() const

View File

@ -24,12 +24,10 @@ using namespace sgpem;
StaticProcess::StaticProcess(const Glib::ustring& name, const unsigned int& arrival, const unsigned int& total, const int& priority) StaticProcess::StaticProcess(const Glib::ustring& name, const unsigned int& arrival, const unsigned int& total, const int& priority)
: StaticSchedulable(name, arrival, total, priority) : StaticSchedulable(name, arrival, total, priority)
{ {}
}
StaticProcess::~StaticProcess() StaticProcess::~StaticProcess()
{ {}
}
Glib::ustring Glib::ustring
StaticProcess::get_type() const StaticProcess::get_type() const

View File

@ -25,8 +25,7 @@ using namespace sgpem;
StaticResource::StaticResource(const Glib::ustring& name, StaticResource::StaticResource(const Glib::ustring& name,
unsigned int places) : unsigned int places) :
_name(name), _places(places) _name(name), _places(places)
{ {}
}
Glib::ustring Glib::ustring
StaticResource::get_name() const StaticResource::get_name() const

View File

@ -27,12 +27,10 @@ StaticSchedulable::StaticSchedulable(const Glib::ustring& name,
const unsigned int& total, const unsigned int& total,
const int& priority) : const int& priority) :
_name(name), _arrival_time(arrival), _total_time(total), _priority(priority) _name(name), _arrival_time(arrival), _total_time(total), _priority(priority)
{ {}
}
StaticSchedulable::~StaticSchedulable() StaticSchedulable::~StaticSchedulable()
{ {}
}
unsigned int unsigned int
StaticSchedulable::get_arrival_time() const StaticSchedulable::get_arrival_time() const

View File

@ -33,8 +33,7 @@ StaticThread::StaticThread(const Glib::ustring& name,
StaticSchedulable(name, arrival_time, 0, base_priority), StaticSchedulable(name, arrival_time, 0, base_priority),
_start_time_delta(arrival_time), _required_cpu_time(0), _start_time_delta(arrival_time), _required_cpu_time(0),
_process(&process) _process(&process)
{ {}
}
unsigned int unsigned int
StaticThread::get_total_cpu_time() const StaticThread::get_total_cpu_time() const

View File

@ -44,10 +44,10 @@ string_to_int(const ustring& str, int& num)
//checks if the string contains only digits //checks if the string contains only digits
if (str.find_first_not_of(allvalid) < str.length()) if (str.find_first_not_of(allvalid) < str.length())
return false; return false;
if (str.substr(1).find_first_not_of(digits) < str.length()-1) if (str.substr(1).find_first_not_of(digits) < str.length() - 1)
return false; return false;
num=0; num = 0;
int multiplier = 1, val; int multiplier = 1, val;
int start; //the position of the biggest digit int start; //the position of the biggest digit
if (str[0] == '-') if (str[0] == '-')
@ -57,7 +57,7 @@ string_to_int(const ustring& str, int& num)
for (int pos = str.length() - 1; pos >= start ; pos--) for (int pos = str.length() - 1; pos >= start ; pos--)
{ {
val = str[pos] - 48; //the INTEGER value of the digit val = str[pos] - 48; //the INTEGER value of the digit
num += val*multiplier; num += val * multiplier;
multiplier *= 10; multiplier *= 10;
} }
//if there is the minus then multiply for -1 //if there is the minus then multiply for -1
@ -80,7 +80,7 @@ int_to_string(const int& num, ustring& str)
str = ""; str = "";
int val = num; int val = num;
bool negative = (val < 0)? true : false; bool negative = (val < 0) ? true : false;
if (negative) val *= -1; if (negative) val *= -1;
while (true) while (true)
@ -101,7 +101,7 @@ float_to_string(const float& f, Glib::ustring& str)
stringstream ss; stringstream ss;
ss << f; ss << f;
char p[20]; char p[20];
ss.getline(p,20); ss.getline(p, 20);
str = p; str = p;
} }

View File

@ -26,38 +26,38 @@
#include <iostream> #include <iostream>
#include "glibmm/ustring.h" #include "glibmm/ustring.h"
/**\brief This function tries to convert a string into an integer value. /**\brief This function tries to convert a string into an integer value.
The string can contain only digits and the minus character (for negative numbers). The string can contain only digits and the minus character (for negative numbers).
\returns TRUE if ths string represent a valid integer number \returns TRUE if ths string represent a valid integer number
\returns FALSE otherwise \returns FALSE otherwise
*/ */
bool SG_DLLEXPORT string_to_int(const Glib::ustring&, int&); bool SG_DLLEXPORT string_to_int(const Glib::ustring&, int&);
/**\brief This function converts an integer value into a string. /**\brief This function converts an integer value into a string.
There is no return value because this function always succeeds. There is no return value because this function always succeeds.
*/ */
void SG_DLLEXPORT int_to_string(const int&, Glib::ustring&); void SG_DLLEXPORT int_to_string(const int&, Glib::ustring&);
/**\brief This function converts a float value into a string. /**\brief This function converts a float value into a string.
There is no return value because this function always succeeds. There is no return value because this function always succeeds.
*/ */
void SG_DLLEXPORT float_to_string(const float&, Glib::ustring&); void SG_DLLEXPORT float_to_string(const float&, Glib::ustring&);
/**\brief This function tries to convert a string into a float value. /**\brief This function tries to convert a string into a float value.
The string can contain only digits, the minus, plus and dot (-+.) characters. If not, The string can contain only digits, the minus, plus and dot (-+.) characters. If not,
the value 0 is assigned. the value 0 is assigned.
There is no return value because this function always succeeds, even if the string is badly formed. There is no return value because this function always succeeds, even if the string is badly formed.
*/ */
void SG_DLLEXPORT string_to_float(const Glib::ustring&, float&); void SG_DLLEXPORT string_to_float(const Glib::ustring&, float&);
#endif #endif

View File

@ -23,6 +23,5 @@
using namespace sgpem; using namespace sgpem;
SubRequest::~SubRequest() SubRequest::~SubRequest()
{ {}
}

View File

@ -23,6 +23,5 @@
using namespace sgpem; using namespace sgpem;
Thread::~Thread() Thread::~Thread()
{ {}
}

View File

@ -40,7 +40,7 @@ namespace sgpem
virtual Process& get_process() = 0; virtual Process& get_process() = 0;
virtual std::vector<Request*> get_requests() = 0; virtual std::vector<Request*> get_requests() = 0;
virtual void serialize(SerializeVisitor& translator) const= 0; virtual void serialize(SerializeVisitor& translator) const = 0;
}; };
} }

View File

@ -29,7 +29,8 @@
#include <stdexcept> #include <stdexcept>
namespace sgpem { namespace sgpem
{
class UserInterruptException; class UserInterruptException;
class SG_DLLEXPORT UserInterruptException : public std::runtime_error class SG_DLLEXPORT UserInterruptException : public std::runtime_error

View File

@ -33,7 +33,8 @@
#include "io_manager.hh" #include "io_manager.hh"
#include "graphical_terminal_io.hh" #include "graphical_terminal_io.hh"
namespace sgpem { namespace sgpem
{
class GraphicalSimulation; class GraphicalSimulation;

View File

@ -44,7 +44,7 @@ GraphicalTerminalIO::GraphicalTerminalIO(TextSimulation* sim)
using namespace Gtk; using namespace Gtk;
set_title(_("Textual Simulation Log")); set_title(_("Textual Simulation Log"));
set_default_size(500,300); set_default_size(500, 300);
Box& mainbox = *manage(new VBox()); Box& mainbox = *manage(new VBox());
add(mainbox); add(mainbox);
@ -130,7 +130,7 @@ GraphicalTerminalIO::read_command()
_text_input.set_text(""); _text_input.set_text("");
_text_input.grab_focus(); _text_input.grab_focus();
return command.substr(f,l-f+1); return command.substr(f, l - f + 1);
} }
bool bool

View File

@ -36,7 +36,8 @@
#include <memory> #include <memory>
namespace sgpem { namespace sgpem
{
// --------------------------------------------- // ---------------------------------------------

View File

@ -26,7 +26,8 @@
#include <glibmm/ustring.h> #include <glibmm/ustring.h>
namespace sgpem { namespace sgpem
{
class IOManager; class IOManager;

View File

@ -55,7 +55,8 @@ using namespace memory;
using Glib::ustring; using Glib::ustring;
static void load_pyloader_plugin() { static void load_pyloader_plugin()
{
// FIXME: this will need to be moved to an // FIXME: this will need to be moved to an
// appropriate PluginManager class in the backend, // appropriate PluginManager class in the backend,
// and the Makefile fixed accordingly (partly done). // and the Makefile fixed accordingly (partly done).
@ -66,7 +67,8 @@ static void load_pyloader_plugin() {
GlobalPreferences& prefs = GlobalPreferences::get_instance(); GlobalPreferences& prefs = GlobalPreferences::get_instance();
GlobalPreferences::dir_iterator it = prefs.modules_dir_begin(); GlobalPreferences::dir_iterator it = prefs.modules_dir_begin();
while(it != prefs.modules_dir_end()) { while(it != prefs.modules_dir_end())
{
std::string pyloader_path = Module::build_path(*it, "pyloader"); std::string pyloader_path = Module::build_path(*it, "pyloader");
pyloader = new Module(pyloader_path); pyloader = new Module(pyloader_path);
if(*pyloader) break; if(*pyloader) break;
@ -101,18 +103,18 @@ main(int argc, char* argv[])
int a_count = argc; int a_count = argc;
char** a_ptr = argv; char** a_ptr = argv;
parse_options(a_count, a_ptr); parse_options(a_count, a_ptr);
filenames.insert(filenames.begin(), a_ptr, a_ptr+a_count); filenames.insert(filenames.begin(), a_ptr, a_ptr + a_count);
} }
load_pyloader_plugin(); load_pyloader_plugin();
// Create an INITIAL STATE // Create an INITIAL STATE
StaticProcess p1("P1", 0,5,1); StaticProcess p1("P1", 0, 5, 1);
StaticProcess p2("P2", 0,5,2); StaticProcess p2("P2", 0, 5, 2);
StaticProcess p3("P3", 5,3,3); StaticProcess p3("P3", 5, 3, 3);
StaticProcess p4("P4", 6,2,3); StaticProcess p4("P4", 6, 2, 3);
StaticProcess p5("P5", 1,2,3); StaticProcess p5("P5", 1, 2, 3);
StaticProcess p6("P6", 10,2,1); StaticProcess p6("P6", 10, 2, 1);
DynamicSchedulable ss1(p1); DynamicSchedulable ss1(p1);
DynamicSchedulable ss2(p2); DynamicSchedulable ss2(p2);

View File

@ -26,7 +26,8 @@
#include <gtkmm/window.h> #include <gtkmm/window.h>
namespace sgpem { namespace sgpem
{
// --------------------------------------------- // ---------------------------------------------

View File

@ -23,10 +23,8 @@
using namespace sgpem; using namespace sgpem;
Observer::Observer() Observer::Observer()
{ {}
}
Observer::~Observer() Observer::~Observer()
{ {}
}

View File

@ -47,7 +47,7 @@ namespace sgpem
interest to this observer happens. interest to this observer happens.
\see ObservedSubject \see ObservedSubject
*/ */
virtual void update() =0; virtual void update() = 0;
private: private:
}; };

View File

@ -69,7 +69,7 @@ parse_options(int& argc, char**& argv)
switch(opt) switch(opt)
{ {
case -1: case - 1:
// We have finished normally // We have finished normally
break; break;
case 'N' : case 'N' :

View File

@ -28,8 +28,7 @@ using namespace memory;
using Glib::usleep; using Glib::usleep;
Simulation::Simulation(): _state(state_paused), _mode(true), _timer_interval(1000) Simulation::Simulation(): _state(state_paused), _mode(true), _timer_interval(1000)
{ {}
}
void void
Simulation::set_timer(const int& t) Simulation::set_timer(const int& t)
@ -97,7 +96,8 @@ Simulation::run() throw(UserInterruptException)
if (_mode) if (_mode)
{ {
do { do
{
// chech for termination // chech for termination
bool all_term = true; bool all_term = true;
smart_ptr<SchedulableQueue> left = h.get_simulation_status_at(h.get_current_time()); smart_ptr<SchedulableQueue> left = h.get_simulation_status_at(h.get_current_time());
@ -135,7 +135,8 @@ Simulation::run() throw(UserInterruptException)
if (_state == state_stopped || _state == state_paused) if (_state == state_stopped || _state == state_paused)
return; return;
} while(true); }
while(true);
} }
//******* STEP by STEP //******* STEP by STEP
@ -185,7 +186,7 @@ Simulation::jump_to(const uint& where) throw(UserInterruptException)
try try
{ {
// executes "where" steps // executes "where" steps
for (uint i=0; i < where; i++) for (uint i = 0; i < where; i++)
run(); run();
} }
catch(UserInterruptException e) catch(UserInterruptException e)

View File

@ -41,7 +41,7 @@ StandardIO::read_command()
using namespace std; using namespace std;
char p[2000]; char p[2000];
cin.getline(p,2000); cin.getline(p, 2000);
ustring command(p); ustring command(p);
@ -53,7 +53,7 @@ StandardIO::read_command()
if(f == ustring::npos) if(f == ustring::npos)
return ""; return "";
return command.substr(f,l-f+1); return command.substr(f, l - f + 1);
} }
bool bool

View File

@ -29,7 +29,8 @@
#include "io_manager.hh" #include "io_manager.hh"
namespace sgpem { namespace sgpem
{
class StandardIO; class StandardIO;

View File

@ -30,7 +30,7 @@
void void
start_gui(int argc, char** argv, TextSimulation& txt) start_gui(int argc, char** argv, TextSimulation& txt)
{ {
Gtk::Main gtk_main(argc,argv); Gtk::Main gtk_main(argc, argv);
GraphicalTerminalIO* gt = new sgpem::GraphicalTerminalIO(&txt); GraphicalTerminalIO* gt = new sgpem::GraphicalTerminalIO(&txt);
memory::smart_ptr<sgpem::IOManager> main_window(gt); memory::smart_ptr<sgpem::IOManager> main_window(gt);

View File

@ -29,9 +29,8 @@ using namespace sgpem;
template<typename T> template<typename T>
PolicyParameters::Parameter<T>::Parameter(Glib::ustring name, const T& value, const T& lower_bound, const T& upper_bound, const bool& required, const T& default_value) PolicyParameters::Parameter<T>::Parameter(Glib::ustring name, const T& value, const T& lower_bound, const T& upper_bound, const bool& required, const T& default_value)
:_name(name), _value(value), _lower_bound(lower_bound), _upper_bound(upper_bound), _is_required(required), _default(default_value) : _name(name), _value(value), _lower_bound(lower_bound), _upper_bound(upper_bound), _is_required(required), _default(default_value)
{ {}
}
template<typename T> template<typename T>
Glib::ustring Glib::ustring

View File

@ -48,7 +48,8 @@ namespace sgpem
private: private:
static Instantiated_class* _instance; static Instantiated_class* _instance;
static Glib::StaticMutex SG_DLLLOCAL _mutex; static Glib::StaticMutex SG_DLLLOCAL _mutex;
}; //~ class Singleton }
; //~ class Singleton
} //~ namespace sgpem } //~ namespace sgpem

View File

@ -20,7 +20,8 @@
#include <new> #include <new>
#include <typeinfo> #include <typeinfo>
namespace memory { namespace memory
{
/** \brief A simple reference counted smart pointer /** \brief A simple reference counted smart pointer
* *
@ -43,7 +44,8 @@ namespace memory {
* from it: its destructor isn't virtual, either. * from it: its destructor isn't virtual, either.
*/ */
template<typename T, bool isArray = false> template<typename T, bool isArray = false>
class smart_ptr { class smart_ptr
{
template<typename T2, bool isArray2> template<typename T2, bool isArray2>
friend class smart_ptr; friend class smart_ptr;
@ -133,7 +135,7 @@ namespace memory {
* the cast isn't successful or doable * the cast isn't successful or doable
*/ */
template<typename U> template<typename U>
smart_ptr<U,isArray> cast_to() throw(std::bad_cast); smart_ptr<U, isArray> cast_to() throw(std::bad_cast);
/** \brief Dynamic cast the stored pointer /** \brief Dynamic cast the stored pointer
* to another type, returning a smart_ptr * to another type, returning a smart_ptr
@ -147,16 +149,18 @@ namespace memory {
* the cast isn't successful or doable * the cast isn't successful or doable
*/ */
template<typename U> template<typename U>
const smart_ptr<U,isArray> cast_to() const throw(std::bad_cast); const smart_ptr<U, isArray> cast_to() const throw(std::bad_cast);
private: private:
template<typename U> template<typename U>
smart_ptr(const smart_ptr<U,isArray>& sptr) throw(std::bad_cast); smart_ptr(const smart_ptr<U, isArray>& sptr) throw(std::bad_cast);
struct contents_type { struct contents_type
{
T* ptr; T* ptr;
unsigned int rc; unsigned int rc;
}* _contents; }
* _contents;
}; };
} }

View File

@ -19,7 +19,8 @@
#include "smartp.hh" #include "smartp.hh"
namespace memory { namespace memory
{
template<typename T, bool isArray> template<typename T, bool isArray>
const smart_ptr<T, isArray> smart_ptr<T, isArray>::null = 0; const smart_ptr<T, isArray> smart_ptr<T, isArray>::null = 0;
@ -161,14 +162,14 @@ namespace memory {
template<typename T, bool isArray> template<typename T, bool isArray>
template<typename U> template<typename U>
smart_ptr<T,isArray>::smart_ptr(const smart_ptr<U,isArray>& sptr) smart_ptr<T, isArray>::smart_ptr(const smart_ptr<U, isArray>& sptr)
throw(std::bad_cast) throw(std::bad_cast)
{ {
if(!sptr._contents->ptr || dynamic_cast<T*>(sptr._contents->ptr) == 0) if(!sptr._contents->ptr || dynamic_cast<T*>(sptr._contents->ptr) == 0)
throw std::bad_cast(); throw std::bad_cast();
// I know, I know... this is Evil(TM): // I know, I know... this is Evil(TM):
_contents = reinterpret_cast<typename smart_ptr<T,isArray>::contents_type*>(sptr._contents); _contents = reinterpret_cast<typename smart_ptr<T, isArray>::contents_type*>(sptr._contents);
(_contents->rc)++; (_contents->rc)++;
} }

View File

@ -51,7 +51,7 @@ using namespace std;
*/ */
class HistoryTester class HistoryTester
{ {
public: public:
HistoryTester(SchedulableQueue sl) HistoryTester(SchedulableQueue sl)
@ -89,7 +89,7 @@ class HistoryTester
return; return;
} }
private: private:
int _history_length; // mirrors the correct length of the history int _history_length; // mirrors the correct length of the history
SchedulableQueue* _get_simulation_status_at[400]; // mirrors the correct content of the history SchedulableQueue* _get_simulation_status_at[400]; // mirrors the correct content of the history
@ -105,12 +105,12 @@ class HistoryTester
if (&History::get_instance() != &History::get_instance()) std::cout << "\nget_instance"; if (&History::get_instance() != &History::get_instance()) std::cout << "\nget_instance";
// checks if the History is long how it should be // checks if the History is long how it should be
if (History::get_instance().get_current_time() != _history_length) std::cout << "\nget_current_time: real: " << History::get_instance().get_current_time() <<", expected " << _history_length<<endl; if (History::get_instance().get_current_time() != _history_length) std::cout << "\nget_current_time: real: " << History::get_instance().get_current_time() << ", expected " << _history_length << endl;
// checks if the History contains the right stuff // checks if the History contains the right stuff
int min = History::get_instance().get_current_time(); int min = History::get_instance().get_current_time();
min = min < _history_length ? min : _history_length; min = min < _history_length ? min : _history_length;
for (int i = 0; i < min+1; i++) for (int i = 0; i < min + 1; i++)
{ {
// watch out here, it's if (NOT ...) operator != was not available. // watch out here, it's if (NOT ...) operator != was not available.
if if
@ -165,9 +165,9 @@ class HistoryTester
status.swap(7, 1); status.swap(7, 1);
for (unsigned int i = 0; i < status.size(); i++) for (unsigned int i = 0; i < status.size(); i++)
{ {
status.get_item_at(i)->give_cpu_time(i%2); status.get_item_at(i)->give_cpu_time(i % 2);
status.get_item_at(i)->set_last_scheduled(_history_length%30); status.get_item_at(i)->set_last_scheduled(_history_length % 30);
status.get_item_at(i)->set_state(i%2 ? DynamicSchedulable::state_running : DynamicSchedulable::state_ready); status.get_item_at(i)->set_state(i % 2 ? DynamicSchedulable::state_running : DynamicSchedulable::state_ready);
} }
return; return;
} }
@ -191,7 +191,7 @@ class HistoryTester
} }
_history_length = _history_length - 1; _history_length = _history_length - 1;
History::get_instance().truncate_at(_history_length-1); History::get_instance().truncate_at(_history_length - 1);
} }
return; return;
} }
@ -210,26 +210,26 @@ main(int argc, char** argv)
command = argv[1]; command = argv[1];
// sets up the test data // sets up the test data
StaticProcess p1("P1", 1,5,1); StaticProcess p1("P1", 1, 5, 1);
StaticProcess p2("P2", 5,55,2); StaticProcess p2("P2", 5, 55, 2);
StaticProcess p3("P3", 36,30,3); StaticProcess p3("P3", 36, 30, 3);
StaticProcess p4("P4", 4,26,3); StaticProcess p4("P4", 4, 26, 3);
StaticProcess p5("P5", 15,200,3); StaticProcess p5("P5", 15, 200, 3);
StaticProcess p6("P6", 6,250,1); StaticProcess p6("P6", 6, 250, 1);
StaticProcess p7("P7", 8,42,15); StaticProcess p7("P7", 8, 42, 15);
StaticProcess p8("P8", 8,56,1); StaticProcess p8("P8", 8, 56, 1);
StaticProcess p9("P9", 9,42,1); StaticProcess p9("P9", 9, 42, 1);
StaticProcess p10("PA", 12,42,1); StaticProcess p10("PA", 12, 42, 1);
StaticProcess p11("PB", 106,42,1); StaticProcess p11("PB", 106, 42, 1);
StaticProcess p12("PC", 100,42,1); StaticProcess p12("PC", 100, 42, 1);
StaticProcess p13("PD", 29,42,18); StaticProcess p13("PD", 29, 42, 18);
StaticProcess p14("PE", 0,42,1); StaticProcess p14("PE", 0, 42, 1);
StaticProcess p15("PF", 2,88,1); StaticProcess p15("PF", 2, 88, 1);
StaticProcess p16("PG", 3666,9,1); StaticProcess p16("PG", 3666, 9, 1);
StaticProcess p17("PH", 5,72,10); StaticProcess p17("PH", 5, 72, 10);
StaticProcess p18("PJ", 6,26,1); StaticProcess p18("PJ", 6, 26, 1);
StaticProcess p19("PK", 10,24,17); StaticProcess p19("PK", 10, 24, 17);
StaticProcess p20("PK2", 11,34,67); // not used! StaticProcess p20("PK2", 11, 34, 67); // not used!
DynamicSchedulable ss1(p1); DynamicSchedulable ss1(p1);
DynamicSchedulable ss2(p2); DynamicSchedulable ss2(p2);

View File

@ -98,7 +98,8 @@ namespace sgpem
int int
main(int, char**) { main(int, char**)
{
using namespace sgpem; using namespace sgpem;
Scheduler::get_instance(); // Forces initialization of scheduler. Scheduler::get_instance(); // Forces initialization of scheduler.

View File

@ -74,23 +74,21 @@ namespace sgpem
} }
virtual ~Policy() virtual ~Policy()
{ {}
}
virtual void configure() virtual void configure()
{ {}
}
virtual void sort_queue() const throw(UserInterruptException) virtual void sort_queue() const throw(UserInterruptException)
{ // here a lot of fun, exactly O(n^2) fun! { // here a lot of fun, exactly O(n^2) fun!
SchedulableQueue sl = History.get_instance().get_simulation_status_at(get_current_time()); SchedulableQueue sl = History.get_instance().get_simulation_status_at(get_current_time());
for (int i = 0; i < sl.size(); i++) for (int i = 0; i < sl.size(); i++)
{ {
for (int j = 0; j < sl.size()-1; j++) for (int j = 0; j < sl.size() - 1; j++)
{ {
if (sl.get_item_at(j).get_schedulable().get_priority() < sl.get_item_at(j+1).get_schedulable().get_priority()) if (sl.get_item_at(j).get_schedulable().get_priority() < sl.get_item_at(j + 1).get_schedulable().get_priority())
{ {
sl.swap(j, j+1); sl.swap(j, j + 1);
} }
} }
@ -150,8 +148,7 @@ namespace sgpem
return PRRPolicy.get_instance(); return PRRPolicy.get_instance();
} }
virtual void init() virtual void init()
{ {}
}
static PolicyManager& get_registered_manager(); static PolicyManager& get_registered_manager();
private: private:
@ -217,13 +214,13 @@ namespace sgpem
class StepForwardTester class StepForwardTester
{ {
} }
// from here and further until the bottom, all to throw away I suppose // from here and further until the bottom, all to throw away I suppose
int int
main(int argc, char** argv) { main(int argc, char** argv)
{
using namespace sgpem; using namespace sgpem;
using Glib::Module; using Glib::Module;
@ -232,26 +229,26 @@ main(int argc, char** argv) {
std::string command(ERERERT); // the sequence of commands to test std::string command(ERERERT); // the sequence of commands to test
// sets up the test data // sets up the test data
StaticProcess p1("P1", 1,5,1); StaticProcess p1("P1", 1, 5, 1);
StaticProcess p2("P2", 5,55,2); StaticProcess p2("P2", 5, 55, 2);
StaticProcess p3("P3", 36,30,3); StaticProcess p3("P3", 36, 30, 3);
StaticProcess p4("P4", 4,26,3); StaticProcess p4("P4", 4, 26, 3);
StaticProcess p5("P5", 15,200,3); StaticProcess p5("P5", 15, 200, 3);
StaticProcess p6("P6", 6,250,1); StaticProcess p6("P6", 6, 250, 1);
StaticProcess p7("P7", 8,42,15); StaticProcess p7("P7", 8, 42, 15);
StaticProcess p8("P8", 8,56,1); StaticProcess p8("P8", 8, 56, 1);
StaticProcess p9("P9", 9,42,1); StaticProcess p9("P9", 9, 42, 1);
StaticProcess p10("PA", 12,42,1); StaticProcess p10("PA", 12, 42, 1);
StaticProcess p11("PB", 106,42,1); StaticProcess p11("PB", 106, 42, 1);
StaticProcess p12("PC", 100,42,1); StaticProcess p12("PC", 100, 42, 1);
StaticProcess p13("PD", 29,42,18); StaticProcess p13("PD", 29, 42, 18);
StaticProcess p14("PE", 0,42,1); StaticProcess p14("PE", 0, 42, 1);
StaticProcess p15("PF", 2,88,1); StaticProcess p15("PF", 2, 88, 1);
StaticProcess p16("PG", 3666,9,1); StaticProcess p16("PG", 3666, 9, 1);
StaticProcess p17("PH", 5,72,10); StaticProcess p17("PH", 5, 72, 10);
StaticProcess p18("PJ", 6,26,1); StaticProcess p18("PJ", 6, 26, 1);
StaticProcess p19("PK", 10,24,17); StaticProcess p19("PK", 10, 24, 17);
StaticProcess p20("PK2", 11,34,67); // not used! StaticProcess p20("PK2", 11, 34, 67); // not used!
DynamicSchedulable ss1(p1); DynamicSchedulable ss1(p1);
DynamicSchedulable ss2(p2); DynamicSchedulable ss2(p2);

View File

@ -34,8 +34,7 @@ using Glib::ustring;
#include "smartp.tcc" #include "smartp.tcc"
TextSimulation::~TextSimulation() TextSimulation::~TextSimulation()
{ {}
}
/** /**
Adds an IO_device and creates a thread which loops the read-parse-execute process Adds an IO_device and creates a thread which loops the read-parse-execute process
@ -70,7 +69,7 @@ TextSimulation::parse_command(pair< pair<TextSimulation*, IOManager*>, const us
str = str.uppercase(); str = str.uppercase();
vector<ustring> arguments; vector<ustring> arguments;
uint f=0; uint f = 0;
static const ustring whitespaces = " \r\b\n\t\a"; static const ustring whitespaces = " \r\b\n\t\a";
//fills the vector with parameters //fills the vector with parameters
while (true) while (true)
@ -87,7 +86,7 @@ TextSimulation::parse_command(pair< pair<TextSimulation*, IOManager*>, const us
//add the token //add the token
arguments.push_back(str.substr(0, f)); arguments.push_back(str.substr(0, f));
//trim the initial whitespaces //trim the initial whitespaces
str = str.substr(f+1); str = str.substr(f + 1);
f = str.find_first_not_of(whitespaces); f = str.find_first_not_of(whitespaces);
str = str.substr(f); str = str.substr(f);
} }
@ -445,10 +444,10 @@ TextSimulation::update()
when = h.get_current_time(); when = h.get_current_time();
smart_ptr<SchedulableQueue> ll = h.get_simulation_status_at(when); smart_ptr<SchedulableQueue> ll = h.get_simulation_status_at(when);
for (uint dev=0; dev < _devices.size(); dev++) for (uint dev = 0; dev < _devices.size(); dev++)
{ {
int_to_string(when, temp); int_to_string(when, temp);
if (when<10) if (when < 10)
_devices[dev]->write_buffer("\n "); _devices[dev]->write_buffer("\n ");
else else
_devices[dev]->write_buffer("\n"); _devices[dev]->write_buffer("\n");