diff --git a/src/backend/history.cc b/src/backend/history.cc index 5c162b6..3f764a0 100644 --- a/src/backend/history.cc +++ b/src/backend/history.cc @@ -23,104 +23,104 @@ using namespace std; using namespace sgpem; using namespace memory; -//History::instance; //static object +//History::instance; //static object History History::_instance(10); //dummy parameter -History::History(int) //private constructor. The parameter is discarded - :_total_time_elapsed(0) -{ -} + +History::History(int) //private constructor. The parameter is discarded + :_total_time_elapsed(0) +{} History& History::getInstance() { - return _instance; + return _instance; } -/** - Returns a pointer to a copy of the SchedulableStatus object relative to this instant. - It can be NULL if time is out of range or if the SimulationStatus object relative to - this instant has no running entities. +/* + Returns a pointer to a copy of the SchedulableStatus object relative to this instant. + It can be NULL if time is out of range or if the SimulationStatus object relative to + this instant has no running entities. */ smart_ptr -History::getScheduledAt (int time) +History::get_scheduled_at(int time) { - if (time >= _total_time_elapsed || time < 0) //out of range - return smart_ptr(NULL); + if (time >= _total_time_elapsed || time < 0) //out of range + return smart_ptr(NULL); - return getSimulationStatusAt(time)->getRunning(); + return get_simulation_status_at(time)->get_running(); } /** - Returns a pointer to a copy of the SimulationStatus object relative to this instant or NULL - if time is out of range. + Returns a pointer to a copy of the SimulationStatus object relative to this instant or NULL + if time is out of range. */ smart_ptr -History::getSimulationStatusAt (int time) +History::get_simulation_status_at(int time) { - if (time >= _total_time_elapsed || time < 0) //out of range - return smart_ptr(NULL); + if (time >= _total_time_elapsed || time < 0) //out of range + return smart_ptr(NULL); - int trascorso = 0; - for(vector::iterator i=_slices.begin(); i < _slices.end(); i++) - if (time < trascorso + i->getDuration()) //FOUND!! - return smart_ptr(new SimulationStatus(i->getSimulationStatus())); - else //Go on... - trascorso += i->getDuration(); + int trascorso = 0; + for(vector::iterator i=_slices.begin(); i < _slices.end(); i++) + if (time < trascorso + i->get_duration()) //FOUND!! + return smart_ptr(new SimulationStatus(i->get_simulation_status())); + else //Go on... + trascorso += i->get_duration(); - //never reached - return smart_ptr(NULL); + //never reached + return smart_ptr(NULL); } int -History::getCurrentTime() +History::get_current_time() { - return _total_time_elapsed; + return _total_time_elapsed; } /** - Appends to the history a SimulationStatus creating a Slice with duration of 1 instant. - Calls the method notify() in quality of ObservedSubject, updating all observers. + Appends to the history a SimulationStatus creating a Slice with duration of 1 instant. + Calls the method notify() in quality of ObservedSubject, updating all observers. */ void -History::enqueueSlice (SimulationStatus status) +History::enqueue_slice(SimulationStatus status) { - if (_slices.size() == 0){ - _slices.push_back(Slice(0, 1, status)); - _total_time_elapsed = 1; - notify(); - return; - } + if(_slices.size() == 0){ + _slices.push_back(Slice(0, 1, status)); + _total_time_elapsed = 1; + notify(); + return; + } - //check the last slice - Slice& last = _slices[_slices.size()-1]; - if (last.getSimulationStatus() == status) //increments the duration by ONE unit - { - last.setDuration(last.getDuration()+1); - } - else //insert a new slice CONTIGUOUS to the last one - { - _slices.push_back(Slice(last.getStartedAt() + last.getDuration(), 1, status)); - } - _total_time_elapsed++; //one instant is passed... - notify(); + //check the last slice + Slice& last = _slices[_slices.size()-1]; + if (last.get_simulation_status() == status) //increments the duration by ONE unit + { + last.set_duration(last.get_duration()+1); + } + else //insert a new slice CONTIGUOUS to the last one + { + _slices.push_back(Slice(last.get_started_at() + last.get_duration(), 1, status)); + } + _total_time_elapsed++; //one instant is passed... + notify(); } /** - Removes all the informations about the simulation following the specified instant. + Removes all the informations about the simulation following the specified instant. */ void -History::truncateAt (int instant) +History::truncate_at(int instant) { - //reach the instant - vector::iterator i = _slices.begin(); - for (int k=0; k < instant; k++) - i++; - //replaces the current vector with the "trimmed" one. - _slices = vector(_slices.begin(),i); - _total_time_elapsed = instant; + //reach the instant + vector::iterator i = _slices.begin(); + for (int k=0; k < instant; k++) + i++; + //replaces the current vector with the "trimmed" one. + _slices = vector(_slices.begin(),i); + _total_time_elapsed = instant; } diff --git a/src/backend/history.hh b/src/backend/history.hh index 6db2780..381090d 100644 --- a/src/backend/history.hh +++ b/src/backend/history.hh @@ -35,7 +35,7 @@ namespace sgpem { -/** \brief Manages the history of the simulation + /** \brief Manages the history of the simulation Manages the history of the simulation from the instant 0 to the current time, i.e. permits to know the state of each schedulable object inside this time interval. @@ -44,28 +44,28 @@ namespace sgpem In a future iteration it will be possible to revert the entire simulation to a state present in the history ("undo operation") -*/ - class History; + */ + class History; - class SG_DLLEXPORT History : public ObservedSubject { - public: + class SG_DLLEXPORT History : public ObservedSubject { + public: - memory::smart_ptr getScheduledAt (int time); - memory::smart_ptr getSimulationStatusAt (int time); - int getCurrentTime(); - void enqueueSlice (sgpem::SimulationStatus status); - void truncateAt (int instant); + memory::smart_ptr get_scheduled_at(int time); + memory::smart_ptr get_simulation_status_at(int time); + int get_current_time(); + void enqueue_slice(sgpem::SimulationStatus status); + void truncate_at(int instant); - static History& getInstance(); + static History& getInstance(); - private: - History(int); //private constructor. The parameter is discarded - static History _instance; - int _total_time_elapsed; - std::vector _slices; - }; + private: + History(int); //private constructor. The parameter is discarded + static History _instance; + int _total_time_elapsed; + std::vector _slices; + }; -} +}//~ namespace sgpem #endif //HISTORY_H diff --git a/src/backend/observedSubject.cc b/src/backend/observedSubject.cc index 475506d..4ff4e89 100644 --- a/src/backend/observedSubject.cc +++ b/src/backend/observedSubject.cc @@ -28,36 +28,36 @@ ObservedSubject::~ObservedSubject() } /** - Calls update() in each Observer + Calls update() in each Observer */ void ObservedSubject::notify() { - for(vector::iterator i = _attached.begin(); i < _attached.end(); i++) - (*i)->update(); + for(vector::iterator i = _attached.begin(); i < _attached.end(); i++) + (*i)->update(); } /** - Attachs an Observer to this ObservedSubject. + Attachs an Observer to this ObservedSubject. */ void ObservedSubject::attach(Observer* o) { - _attached.push_back(o); + _attached.push_back(o); } /** - Detachs the observer from this ObservedSubject. + Detachs the observer from this ObservedSubject. */ bool ObservedSubject::detach(Observer* o) { - vector::iterator i = find(_attached.begin(), _attached.end(), o); - if (i == _attached.end()) - return false; + vector::iterator i = find(_attached.begin(), _attached.end(), o); + if (i == _attached.end()) + return false; - _attached.erase(i); // FOUND and POPPED - return true; + _attached.erase(i); // FOUND and POPPED + return true; } diff --git a/src/backend/observedSubject.hh b/src/backend/observedSubject.hh index b2e39f0..4b65886 100644 --- a/src/backend/observedSubject.hh +++ b/src/backend/observedSubject.hh @@ -30,25 +30,26 @@ namespace sgpem { - /** - Abstract class which represents an observed entity who calls Update() in all Observer objects. - See "Observer Pattern" for more information. - */ - class ObservedSubject; - - class SG_DLLEXPORT ObservedSubject - { - public: - virtual ~ObservedSubject() =0; - - void notify(); - void attach(sgpem::Observer*); - bool detach(sgpem::Observer*); - - private: - std::vector _attached; - }; -} + /** + Abstract class which represents an observed entity who calls Update() in all Observer objects. + See "Observer Pattern" for more information. + */ + class ObservedSubject; + + class SG_DLLEXPORT ObservedSubject + { + public: + virtual ~ObservedSubject() =0; + + void notify(); + void attach(sgpem::Observer*); + bool detach(sgpem::Observer*); + + private: + std::vector _attached; + }; + +} //~ namespace sgpem #endif diff --git a/src/backend/process.cc b/src/backend/process.cc index 29be6e4..043d8c5 100644 --- a/src/backend/process.cc +++ b/src/backend/process.cc @@ -23,7 +23,7 @@ using namespace sgpem; Process::Process(const Glib::ustring& name, const unsigned int& arrival, const unsigned int& total, const int& priority) - : Schedulable(name, arrival, total, priority) + : Schedulable(name, arrival, total, priority) { } @@ -32,7 +32,7 @@ Process::~Process() } Glib::ustring -Process::getType() const +Process::get_type() const { - return "Process"; + return "Process"; } diff --git a/src/backend/process.hh b/src/backend/process.hh index 2bb2515..bedfcbe 100644 --- a/src/backend/process.hh +++ b/src/backend/process.hh @@ -29,22 +29,22 @@ namespace sgpem { - class Process; + class Process; /** \brief Represents a program in execution. - It IS a Schedulable object. + It IS a Schedulable object. */ - class SG_DLLEXPORT Process : public Schedulable - { - public: - Process(const Glib::ustring& name, const unsigned int& arrival, const unsigned int& total, const int& priority); - ~Process(); + class SG_DLLEXPORT Process : public Schedulable + { + public: + Process(const Glib::ustring& name, const unsigned int& arrival, const unsigned int& total, const int& priority); + ~Process(); - Glib::ustring getType() const; + Glib::ustring get_type() const; - private: - }; + private: + }; } diff --git a/src/backend/schedulable.cc b/src/backend/schedulable.cc index 5229949..3340fba 100644 --- a/src/backend/schedulable.cc +++ b/src/backend/schedulable.cc @@ -23,10 +23,10 @@ using namespace sgpem; Schedulable::Schedulable(const Glib::ustring& name, - const unsigned int& arrival, - const unsigned int& total, - const int& priority): - _name(name), _arrival_time(arrival), _total_time(total), _priority(priority) + const unsigned int& arrival, + const unsigned int& total, + const int& priority): + _name(name), _arrival_time(arrival), _total_time(total), _priority(priority) {} @@ -35,27 +35,27 @@ Schedulable::~Schedulable() unsigned int -Schedulable::getArrivalTime() const +Schedulable::get_arrival_time() const { return _arrival_time; } unsigned int -Schedulable::getTotalCPUTime() const +Schedulable::get_total_cpu_time() const { return _total_time; } int -Schedulable::getPriority() const +Schedulable::get_priority() const { return _priority; } Glib::ustring -Schedulable::getName() const +Schedulable::get_name() const { - return _name; + return _name; } diff --git a/src/backend/schedulable.hh b/src/backend/schedulable.hh index 059fe3a..019715a 100644 --- a/src/backend/schedulable.hh +++ b/src/backend/schedulable.hh @@ -39,18 +39,18 @@ namespace sgpem class SG_DLLEXPORT Schedulable { public: - Schedulable(const Glib::ustring& name, const unsigned int& arrival, const unsigned int& total, const int& priority); + Schedulable(const Glib::ustring& name, const unsigned int& arrival, const unsigned int& total, const int& priority); virtual ~Schedulable() = 0; - virtual unsigned int getArrivalTime() const; - unsigned int getTotalCPUTime() const; - int getPriority() const; - Glib::ustring getName() const; - virtual Glib::ustring getType() const =0; + virtual unsigned int get_arrival_time() const; + unsigned int get_total_cpu_time() const; + int get_priority() const; + Glib::ustring get_name() const; + virtual Glib::ustring get_type() const = 0; private: Glib::ustring _name; - unsigned int _arrival_time; + unsigned int _arrival_time; unsigned int _total_time; int _priority; diff --git a/src/backend/schedulableStatus.cc b/src/backend/schedulableStatus.cc index b128afb..13ba721 100644 --- a/src/backend/schedulableStatus.cc +++ b/src/backend/schedulableStatus.cc @@ -22,59 +22,59 @@ using namespace sgpem; using namespace std; -SchedulableStatus::SchedulableStatus(const Schedulable& obj): - _ref(&obj), _last(-1), _timeLeft(obj.getTotalCPUTime()), _myState(state_future) +SchedulableStatus::SchedulableStatus(const Schedulable& obj) + : _ref(&obj), _last(-1), _time_left(obj.get_total_cpu_time()), _my_state(state_future) { } int -SchedulableStatus::getCpuTimeLeft() const +SchedulableStatus::get_cpu_time_left() const { - return _timeLeft; + return _time_left; } void -SchedulableStatus::giveCpuTime(const int& time) +SchedulableStatus::give_cpu_time(const int& time) { - _timeLeft -= time; - if (_timeLeft < 0) - _timeLeft = 0; + _time_left -= time; + if (_time_left < 0) + _time_left = 0; } void -SchedulableStatus::setLastScheduled(const int& time) +SchedulableStatus::set_last_scheduled(const int& time) { - _last = time; + _last = time; } int -SchedulableStatus::getLastScheduled() const +SchedulableStatus::get_last_scheduled() const { - return _last; + return _last; } SchedulableStatus::state -SchedulableStatus::getState() const +SchedulableStatus::get_state() const { - return _myState; + return _my_state; } void -SchedulableStatus::setState(state s) +SchedulableStatus::set_state(state s) { - _myState = s; + _my_state = s; } const Schedulable* -SchedulableStatus::getSchedulable() const +SchedulableStatus::get_schedulable() const { - return _ref; + return _ref; } bool SchedulableStatus::operator==(const SchedulableStatus& dx) const { - return (_ref==dx._ref)&&(_last==dx._last)&&(_timeLeft==dx._timeLeft)&&(_myState==dx._myState); + return (_ref==dx._ref)&&(_last==dx._last)&&(_time_left==dx._time_left)&&(_my_state==dx._my_state); } - \ No newline at end of file + diff --git a/src/backend/schedulableStatus.hh b/src/backend/schedulableStatus.hh index 30d7c34..c3885c9 100644 --- a/src/backend/schedulableStatus.hh +++ b/src/backend/schedulableStatus.hh @@ -27,47 +27,47 @@ namespace sgpem { - class SchedulableStatus; - /** \brief Desribes the state of a schedulable entity in a particular moment of the simulation + class SchedulableStatus; + /** \brief Desribes the state of a schedulable entity in a particular moment of the simulation - This class desribes the state of a schedulable entity in a particular moment of the simulation. - Stores part of informations deeded by Scheduler to manage processes and other ones. + This class desribes the state of a schedulable entity in a particular moment of the simulation. + Stores part of informations deeded by Scheduler to manage processes and other ones. - Objects SchedulableStatus are created by Scheduler and destroyed by SimulationStatus if they are linked to it - or by Scheduler. - */ -class SG_DLLEXPORT SchedulableStatus -{ - public: - enum state - { - state_running, - state_ready, - state_blocked, - state_future, - state_terminated - }; + Objects SchedulableStatus are created by Scheduler and destroyed by SimulationStatus if they are linked to it + or by Scheduler. + */ + class SG_DLLEXPORT SchedulableStatus + { + public: + enum state + { + state_running, + state_ready, + state_blocked, + state_future, + state_terminated + }; - SchedulableStatus(const Schedulable& obj); - //SchedulableStatus(const SchedulableStatus& obj); //copy constructor - bool operator==(const SchedulableStatus&) const; + SchedulableStatus(const Schedulable& obj); + //SchedulableStatus(const SchedulableStatus& obj); //copy constructor + bool operator==(const SchedulableStatus&) const; - int getCpuTimeLeft() const; - void giveCpuTime(const int& time); - void setLastScheduled(const int& time); - int getLastScheduled() const; - state getState() const; - void setState(state s); - const Schedulable* getSchedulable() const; + int get_cpu_time_left() const; + void give_cpu_time(const int& time); + void set_last_scheduled(const int& time); + int get_last_scheduled() const; + state get_state() const; + void set_state(state s); + const Schedulable* get_schedulable() const; - private: - const Schedulable* _ref; - int _last; - int _timeLeft; - state _myState; + private: + const Schedulable* _ref; + int _last; + int _time_left; + state _my_state; -}; + }; } diff --git a/src/backend/simulationStatus.cc b/src/backend/simulationStatus.cc index e712a63..3bdb920 100644 --- a/src/backend/simulationStatus.cc +++ b/src/backend/simulationStatus.cc @@ -23,74 +23,73 @@ using namespace sgpem; using namespace std; using namespace memory; - /** \brief Creates the SimulationStatus object with no SchedulableStatus object +/** \brief Creates the SimulationStatus object with no SchedulableStatus object - */ + */ SimulationStatus::SimulationStatus() { } SimulationStatus::SimulationStatus(const SimulationStatus& dx) - :_set(dx._set) + :_set(dx._set) { } - /** \brief Adds a SchedulableStatus which represents a running Schedulable object. +/** \brief Adds a SchedulableStatus which represents a running Schedulable object. - Adds a SchedulableStatus which represents a running Schedulable object. - Note that a copy of SchedulableStatus will be created - */ + Adds a SchedulableStatus which represents a running Schedulable object. + Note that a copy of SchedulableStatus will be created +*/ void -SimulationStatus::setRunning(SchedulableStatus entity) +SimulationStatus::set_running(SchedulableStatus entity) { - if (entity.getState() != SchedulableStatus::state_running) - entity.setState(SchedulableStatus::state_running); - _set.push_back(entity); + if (entity.get_state() != SchedulableStatus::state_running) + entity.set_state(SchedulableStatus::state_running); + _set.push_back(entity); } - /** \brief Looks for a running Schedulable object and returns ist state. - Looks for a running Schedulable object and returns its state. There can be only - one running schedulable object. If no running schedulable object is found will be returned - the NULL pointer. - */ +/** \brief Looks for a running Schedulable object and returns ist state. + Looks for a running Schedulable object and returns its state. There can be only + one running schedulable object. If no running schedulable object is found will be returned + the NULL pointer. +*/ smart_ptr -SimulationStatus::getRunning() +SimulationStatus::get_running() { - for (list::iterator f=_set.begin(); f != _set.end(); f++) - if (f->getState() == SchedulableStatus::state_running){ //there can be only ONE running schedulable objext - return smart_ptr(new SchedulableStatus(*f)); - } - return smart_ptr(NULL); + for (list::iterator f=_set.begin(); f != _set.end(); f++) + if (f->get_state() == SchedulableStatus::state_running){ //there can be only ONE running schedulable objext + return smart_ptr(new SchedulableStatus(*f)); + } + return smart_ptr(NULL); } smart_ptr -SimulationStatus::getRunning() const +SimulationStatus::get_running() const { - for (list::const_iterator f=_set.begin(); f != _set.end(); f++) - if (f->getState() == SchedulableStatus::state_running){ //there can be only ONE running schedulable objext - return smart_ptr(new SchedulableStatus(*f)); - } - return smart_ptr(NULL); //NOT FOUND RUNNING ENTITIES + for (list::const_iterator f=_set.begin(); f != _set.end(); f++) + if (f->get_state() == SchedulableStatus::state_running){ //there can be only ONE running schedulable objext + return smart_ptr(new SchedulableStatus(*f)); + } + return smart_ptr(NULL); //NOT FOUND RUNNING ENTITIES } - /** - \brief Returns TRUE if the two objects have the same SchedulableStatus objects - */ +/** + \brief Returns TRUE if the two objects have the same SchedulableStatus objects +*/ bool SimulationStatus::operator==(const SimulationStatus& dx) const { - if (_set.size() != dx._set.size()) - return false; + if (_set.size() != dx._set.size()) + return false; - //check if dx has ALL and ONLY the elements holded by _set with no order importance - for(list::const_iterator f=_set.begin(); f != _set.end(); f++) - if (find(dx._set.begin(), dx._set.end(), *f) == dx._set.end()) //element NOT found!! - return false; + //check if dx has ALL and ONLY the elements holded by _set with no order importance + for(list::const_iterator f=_set.begin(); f != _set.end(); f++) + if (find(dx._set.begin(), dx._set.end(), *f) == dx._set.end()) //element NOT found!! + return false; - - return true; + return true; } diff --git a/src/backend/simulationStatus.hh b/src/backend/simulationStatus.hh index c1596f4..f78ad1e 100644 --- a/src/backend/simulationStatus.hh +++ b/src/backend/simulationStatus.hh @@ -29,30 +29,32 @@ namespace sgpem { - class SimulationStatus; + class SimulationStatus; /** \brief Keeps informatios about the configuration of the simulation - Keeps informatios about the configuration of the simulation: which process is - running and other infos (since M02+) + Keeps informatios about the configuration of the simulation: which process is + running and other infos (since M02+) */ - class SG_DLLEXPORT SimulationStatus - { - public: - SimulationStatus(); - SimulationStatus(const SimulationStatus&); + class SG_DLLEXPORT SimulationStatus + { + public: + SimulationStatus(); + SimulationStatus(const SimulationStatus&); - bool operator==(const SimulationStatus&) const; - memory::smart_ptr getRunning(); //this method isn't const because it returns a pointer which CAN alter the object! - memory::smart_ptr getRunning() const; - void setRunning(SchedulableStatus); + bool operator==(const SimulationStatus&) const; - private: - //I used a list instead of a vector because this one could reallocate the internal elements - //making pointers returned by getRunning() point to nothing! SEGMENTATION-FAULT :-O - std::list _set; - }; + //this method isn't const because it returns a pointer which CAN alter the object! + memory::smart_ptr get_running(); + memory::smart_ptr get_running() const; + void set_running(SchedulableStatus); + + private: + //I used a list instead of a vector because this one could reallocate the internal elements + //making pointers returned by getRunning() point to nothing! SEGMENTATION-FAULT :-O + std::list _set; + }; } diff --git a/src/backend/slice.cc b/src/backend/slice.cc index ebb4fd8..4ecb93f 100644 --- a/src/backend/slice.cc +++ b/src/backend/slice.cc @@ -24,30 +24,30 @@ using namespace std; Slice::Slice(const int& start, const int& duration, const SimulationStatus& status) - : _ref(status), _started_at(start), _duration(duration) + : _ref(status), _started_at(start), _duration(duration) { } SimulationStatus& -Slice::getSimulationStatus() +Slice::get_simulation_status() { - return _ref; + return _ref; } int -Slice::getStartedAt() const +Slice::get_started_at() const { - return _started_at; + return _started_at; } int -Slice::getDuration() const +Slice::get_duration() const { - return _duration; + return _duration; } void -Slice::setDuration(const int& i) +Slice::set_duration(const int& i) { - _duration = i; -} \ No newline at end of file + _duration = i; +} diff --git a/src/backend/slice.hh b/src/backend/slice.hh index ef90099..5d31f2e 100644 --- a/src/backend/slice.hh +++ b/src/backend/slice.hh @@ -27,31 +27,31 @@ namespace sgpem { - class Slice; + class Slice; /** \brief Represents a slice of time during which some characteristic of the state of the simulation are constant - Represents a slice of time during which some characteristic of the state of the simulation are constant. - It holds a SimulationStatus object which can be accesse through getSimulationStatus() + Represents a slice of time during which some characteristic of the state of the simulation are constant. + It holds a SimulationStatus object which can be accesse through getSimulationStatus() */ - class SG_DLLEXPORT Slice - { - public: - Slice(const int& start, const int& duration, const SimulationStatus& status); + class SG_DLLEXPORT Slice + { + public: + Slice(const int& start, const int& duration, const SimulationStatus& status); - SimulationStatus& getSimulationStatus(); - int getStartedAt() const; - int getDuration() const; - void setDuration(const int&); + SimulationStatus& get_simulation_status(); + int get_started_at() const; + int get_duration() const; + void set_duration(const int&); - private: - SimulationStatus _ref; - int _started_at; - int _duration; - }; + private: + SimulationStatus _ref; + int _started_at; + int _duration; + }; -} +} //~ namespace sgpem #endif diff --git a/src/graphicalterminalio.cc b/src/graphicalterminalio.cc index 33acf54..a28194b 100644 --- a/src/graphicalterminalio.cc +++ b/src/graphicalterminalio.cc @@ -27,15 +27,13 @@ #include #include -GraphicalTerminalIO::GraphicalTerminalIO() -{ +using namespace sgpem; -} +GraphicalTerminalIO::GraphicalTerminalIO() +{} GraphicalTerminalIO::~GraphicalTerminalIO() -{ - -} +{} GraphicalTerminalIO::size_type GraphicalTerminalIO::write_buffer(const Glib::ustring& buffer) diff --git a/src/graphicalterminalio.hh b/src/graphicalterminalio.hh index d3fe8a2..c075083 100644 --- a/src/graphicalterminalio.hh +++ b/src/graphicalterminalio.hh @@ -31,26 +31,31 @@ #include "iomanager.hh" -// --------------------------------------------- +namespace sgpem { -class GraphicalTerminalIO; - -// --------------------------------------------- - -/** \brief - * - * ... long desc ... */ -class GraphicalTerminalIO : public IOManager, public Gtk::VBox { - typedef unsigned int size_type; -public: - GraphicalTerminalIO(); - virtual ~GraphicalTerminalIO(); + // --------------------------------------------- - virtual size_type write_buffer(const Glib::ustring& buffer); - virtual size_type read_command(Glib::ustring& buffer) const; -private: - Gtk::TextView text_output; - Gtk::Entry text_input; -}; + class GraphicalTerminalIO; + + // --------------------------------------------- + + /** \brief + * + * ... long desc ... */ + class GraphicalTerminalIO : public IOManager, public Gtk::VBox + { + typedef unsigned int size_type; + public: + GraphicalTerminalIO(); + virtual ~GraphicalTerminalIO(); + + virtual size_type write_buffer(const Glib::ustring& buffer); + virtual size_type read_command(Glib::ustring& buffer) const; + private: + Gtk::TextView text_output; + Gtk::Entry text_input; + }; + +} #endif diff --git a/src/iomanager.hh b/src/iomanager.hh index ec13cd9..e765cd5 100644 --- a/src/iomanager.hh +++ b/src/iomanager.hh @@ -26,22 +26,27 @@ #include -// --------------------------------------------- +namespace sgpem { -class IOManager; + // --------------------------------------------- + + class IOManager; + + // --------------------------------------------- + + /** \brief + * + * ... long desc ... */ + class IOManager + { + typedef unsigned int size_type; + public: + virtual ~IOManager() {} + + virtual size_type write_buffer(const Glib::ustring& buffer) = 0; + virtual size_type read_command(Glib::ustring& buffer) const = 0; + }; -// --------------------------------------------- - -/** \brief - * - * ... long desc ... */ -class IOManager { - typedef unsigned int size_type; -public: - virtual ~IOManager() {} - - virtual size_type write_buffer(const Glib::ustring& buffer) = 0; - virtual size_type read_command(Glib::ustring& buffer) const = 0; -}; +} #endif diff --git a/src/main.cc b/src/main.cc index b87d894..81093fd 100644 --- a/src/main.cc +++ b/src/main.cc @@ -37,14 +37,14 @@ #include #include - using namespace std; - using namespace sgpem; - using namespace memory; +using namespace std; +using namespace sgpem; +using namespace memory; int main(int argc, char* argv[]) { - + using namespace sgpem; // Set up gettext support setlocale(LC_ALL, ""); @@ -61,59 +61,59 @@ main(int argc, char* argv[]) filenames.insert(filenames.begin(), a_ptr, a_ptr+a_count); } */ -//start_gui(argc, argv); + //start_gui(argc, argv); //SMOKE-TEST for backend classes - cout << "\n\n********************************"; - Process p1("P1", 0,10,1); - Process p2("P2", 0,30,2); - Process p3("P3", 5,15,3); - - SchedulableStatus ss1(p1); - SchedulableStatus ss2(p2); - SchedulableStatus ss3(p3); - - SimulationStatus sim1; sim1.setRunning(p1); - SimulationStatus sim2; sim2.setRunning(p2); - SimulationStatus sim3; sim3.setRunning(p3); - - History h(History::getInstance()); - - h.enqueueSlice(sim1); - h.enqueueSlice(sim1); - h.enqueueSlice(sim2); - h.enqueueSlice(sim1); - h.enqueueSlice(sim2); - h.enqueueSlice(sim1); - h.enqueueSlice(sim2); - h.enqueueSlice(sim3); - h.enqueueSlice(sim3); - h.enqueueSlice(sim1); - h.enqueueSlice(sim3); - h.enqueueSlice(sim1); - - h.truncateAt(3); - - smart_ptr quale; - - quale = h.getSimulationStatusAt(0); - if (quale) cout << "\n" << quale->getRunning()->getSchedulable()->getName(); else cout << "NO"; - quale = h.getSimulationStatusAt(1); - if (quale) cout << "\n" << quale->getRunning()->getSchedulable()->getName(); else cout << "NO"; - quale = h.getSimulationStatusAt(2); - if (quale) cout << "\n" << quale->getRunning()->getSchedulable()->getName(); else cout << "NO"; - - h.truncateAt(2); - - smart_ptr quale2; - quale2 = h.getScheduledAt(0); - if (quale2) cout << "\n" << quale2->getSchedulable()->getName(); else cout << "NO"; - quale2 = h.getScheduledAt(1); - if (quale2) cout << "\n" << quale2->getSchedulable()->getName(); else cout << "NO"; - quale2 = h.getScheduledAt(2); - if (quale2) cout << "\n" << quale2->getSchedulable()->getName(); else cout << "NO"; + cout << "\n\n********************************"; + Process p1("P1", 0,10,1); + Process p2("P2", 0,30,2); + Process p3("P3", 5,15,3); - - cout << "\n\n"; + SchedulableStatus ss1(p1); + SchedulableStatus ss2(p2); + SchedulableStatus ss3(p3); + + SimulationStatus sim1; sim1.set_running(p1); + SimulationStatus sim2; sim2.set_running(p2); + SimulationStatus sim3; sim3.set_running(p3); + + History h(History::getInstance()); + + h.enqueue_slice(sim1); + h.enqueue_slice(sim1); + h.enqueue_slice(sim2); + h.enqueue_slice(sim1); + h.enqueue_slice(sim2); + h.enqueue_slice(sim1); + h.enqueue_slice(sim2); + h.enqueue_slice(sim3); + h.enqueue_slice(sim3); + h.enqueue_slice(sim1); + h.enqueue_slice(sim3); + h.enqueue_slice(sim1); + + h.truncate_at(3); + + smart_ptr quale; + + quale = h.get_simulation_status_at(0); + if (quale) cout << "\n" << quale->get_running()->get_schedulable()->get_name(); else cout << "NO"; + quale = h.get_simulation_status_at(1); + if (quale) cout << "\n" << quale->get_running()->get_schedulable()->get_name(); else cout << "NO"; + quale = h.get_simulation_status_at(2); + if (quale) cout << "\n" << quale->get_running()->get_schedulable()->get_name(); else cout << "NO"; + + h.truncate_at(2); + + smart_ptr quale2; + quale2 = h.get_scheduled_at(0); + if (quale2) cout << "\n" << quale2->get_schedulable()->get_name(); else cout << "NO"; + quale2 = h.get_scheduled_at(1); + if (quale2) cout << "\n" << quale2->get_schedulable()->get_name(); else cout << "NO"; + quale2 = h.get_scheduled_at(2); + if (quale2) cout << "\n" << quale2->get_schedulable()->get_name(); else cout << "NO"; + + + cout << "\n\n"; return 0; } diff --git a/src/mainwindow.cc b/src/mainwindow.cc index fcb39f2..9be50b6 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -29,18 +29,20 @@ #include #include +using namespace sgpem; + MainWindow::MainWindow() { set_title(PACKAGE_STRING); set_default_size(800, 600); - + Gtk::Box* mainbox = manage(new Gtk::VBox()); add(*mainbox); - + Gtk::Button* bt_exit = manage(new Gtk::Button(_("Exit"))); bt_exit->signal_clicked().connect(sigc::ptr_fun(Gtk::Main::quit)); mainbox->pack_start(*bt_exit); - + show_all_children(); } diff --git a/src/mainwindow.hh b/src/mainwindow.hh index 7e69c22..53246c3 100644 --- a/src/mainwindow.hh +++ b/src/mainwindow.hh @@ -18,31 +18,36 @@ // along with SGPEMv2; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef GTKGUI_MAINWINDOW_HH -#define GTKGUI_MAINWINDOW_HH 1 +#ifndef MAINWINDOW_HH +#define MAINWINDOW_HH 1 #include "config.h" #include "gettext.h" #include -// --------------------------------------------- - -class MainWindow; - -// --------------------------------------------- - -/** \brief The main program window - * - * This is the main simulation window displayed - * when the program is run with a GUI */ -class MainWindow : public Gtk::Window { -public: - MainWindow(); - virtual ~MainWindow(); +namespace sgpem { -private: + // --------------------------------------------- -}; + class MainWindow; + + // --------------------------------------------- + + /** \brief The main program window + * + * This is the main simulation window displayed + * when the program is run with a GUI */ + class MainWindow : public Gtk::Window + { + public: + MainWindow(); + virtual ~MainWindow(); + + private: + + }; + +} //~ namespace sgpem #endif diff --git a/src/observer.hh b/src/observer.hh index 432fcfc..95d428c 100644 --- a/src/observer.hh +++ b/src/observer.hh @@ -25,23 +25,26 @@ namespace sgpem { - /** - Abstract class which represents an observed entity who calls Update() in all Observer objects. - See "Observer Pattern" for more information. - */ - class Observer; - - class SG_DLLEXPORT Observer - { - public: - virtual ~Observer()=0; - - virtual void update(); - - private: - }; - + class Observer; + + /** \brief An abstract class helping to implemen an Observer Pattern + * + * Abstract class which represents an observed entity which calls + * update() on all Observer objects. + * + * See the "Observer Pattern" for more information. + */ + class SG_DLLEXPORT Observer + { + public: + virtual ~Observer() = 0; + + virtual void update(); + + private: + }; + } -#endif \ No newline at end of file +#endif diff --git a/src/startgui.cc b/src/startgui.cc index d153b55..506700d 100644 --- a/src/startgui.cc +++ b/src/startgui.cc @@ -30,6 +30,6 @@ void start_gui(int argc, char** argv) { Gtk::Main gtk_main(argc,argv); - MainWindow main_window; + sgpem::MainWindow main_window; Gtk::Main::run(main_window); }