- Fixed code to follow function naming conventions a bit more
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@306 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
e8b28cc2ec
commit
68a0cef9d9
|
@ -26,10 +26,10 @@ using namespace memory;
|
||||||
//History::instance; //static object
|
//History::instance; //static object
|
||||||
History History::_instance(10); //dummy parameter
|
History History::_instance(10); //dummy parameter
|
||||||
|
|
||||||
|
|
||||||
History::History(int) //private constructor. The parameter is discarded
|
History::History(int) //private constructor. The parameter is discarded
|
||||||
:_total_time_elapsed(0)
|
:_total_time_elapsed(0)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
History&
|
History&
|
||||||
|
@ -39,18 +39,18 @@ History::getInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
Returns a pointer to a copy of the SchedulableStatus object relative to this instant.
|
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
|
It can be NULL if time is out of range or if the SimulationStatus object relative to
|
||||||
this instant has no running entities.
|
this instant has no running entities.
|
||||||
*/
|
*/
|
||||||
smart_ptr<const SchedulableStatus>
|
smart_ptr<const SchedulableStatus>
|
||||||
History::getScheduledAt (int time)
|
History::get_scheduled_at(int time)
|
||||||
{
|
{
|
||||||
if (time >= _total_time_elapsed || time < 0) //out of range
|
if (time >= _total_time_elapsed || time < 0) //out of range
|
||||||
return smart_ptr<const SchedulableStatus>(NULL);
|
return smart_ptr<const SchedulableStatus>(NULL);
|
||||||
|
|
||||||
return getSimulationStatusAt(time)->getRunning();
|
return get_simulation_status_at(time)->get_running();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,24 +58,24 @@ History::getScheduledAt (int time)
|
||||||
if time is out of range.
|
if time is out of range.
|
||||||
*/
|
*/
|
||||||
smart_ptr<const SimulationStatus>
|
smart_ptr<const SimulationStatus>
|
||||||
History::getSimulationStatusAt (int time)
|
History::get_simulation_status_at(int time)
|
||||||
{
|
{
|
||||||
if (time >= _total_time_elapsed || time < 0) //out of range
|
if (time >= _total_time_elapsed || time < 0) //out of range
|
||||||
return smart_ptr<const SimulationStatus>(NULL);
|
return smart_ptr<const SimulationStatus>(NULL);
|
||||||
|
|
||||||
int trascorso = 0;
|
int trascorso = 0;
|
||||||
for(vector<Slice>::iterator i=_slices.begin(); i < _slices.end(); i++)
|
for(vector<Slice>::iterator i=_slices.begin(); i < _slices.end(); i++)
|
||||||
if (time < trascorso + i->getDuration()) //FOUND!!
|
if (time < trascorso + i->get_duration()) //FOUND!!
|
||||||
return smart_ptr<const SimulationStatus>(new SimulationStatus(i->getSimulationStatus()));
|
return smart_ptr<const SimulationStatus>(new SimulationStatus(i->get_simulation_status()));
|
||||||
else //Go on...
|
else //Go on...
|
||||||
trascorso += i->getDuration();
|
trascorso += i->get_duration();
|
||||||
|
|
||||||
//never reached
|
//never reached
|
||||||
return smart_ptr<const SimulationStatus>(NULL);
|
return smart_ptr<const SimulationStatus>(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
History::getCurrentTime()
|
History::get_current_time()
|
||||||
{
|
{
|
||||||
return _total_time_elapsed;
|
return _total_time_elapsed;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ History::getCurrentTime()
|
||||||
Calls the method notify() in quality of ObservedSubject, updating all observers.
|
Calls the method notify() in quality of ObservedSubject, updating all observers.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
History::enqueueSlice (SimulationStatus status)
|
History::enqueue_slice(SimulationStatus status)
|
||||||
{
|
{
|
||||||
if(_slices.size() == 0){
|
if(_slices.size() == 0){
|
||||||
_slices.push_back(Slice(0, 1, status));
|
_slices.push_back(Slice(0, 1, status));
|
||||||
|
@ -96,13 +96,13 @@ History::enqueueSlice (SimulationStatus status)
|
||||||
|
|
||||||
//check the last slice
|
//check the last slice
|
||||||
Slice& last = _slices[_slices.size()-1];
|
Slice& last = _slices[_slices.size()-1];
|
||||||
if (last.getSimulationStatus() == status) //increments the duration by ONE unit
|
if (last.get_simulation_status() == status) //increments the duration by ONE unit
|
||||||
{
|
{
|
||||||
last.setDuration(last.getDuration()+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
|
||||||
{
|
{
|
||||||
_slices.push_back(Slice(last.getStartedAt() + last.getDuration(), 1, status));
|
_slices.push_back(Slice(last.get_started_at() + last.get_duration(), 1, status));
|
||||||
}
|
}
|
||||||
_total_time_elapsed++; //one instant is passed...
|
_total_time_elapsed++; //one instant is passed...
|
||||||
notify();
|
notify();
|
||||||
|
@ -112,7 +112,7 @@ History::enqueueSlice (SimulationStatus status)
|
||||||
Removes all the informations about the simulation following the specified instant.
|
Removes all the informations about the simulation following the specified instant.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
History::truncateAt (int instant)
|
History::truncate_at(int instant)
|
||||||
{
|
{
|
||||||
//reach the instant
|
//reach the instant
|
||||||
vector<Slice>::iterator i = _slices.begin();
|
vector<Slice>::iterator i = _slices.begin();
|
||||||
|
|
|
@ -50,11 +50,11 @@ namespace sgpem
|
||||||
class SG_DLLEXPORT History : public ObservedSubject {
|
class SG_DLLEXPORT History : public ObservedSubject {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
memory::smart_ptr<const sgpem::SchedulableStatus> getScheduledAt (int time);
|
memory::smart_ptr<const sgpem::SchedulableStatus> get_scheduled_at(int time);
|
||||||
memory::smart_ptr<const sgpem::SimulationStatus> getSimulationStatusAt (int time);
|
memory::smart_ptr<const sgpem::SimulationStatus> get_simulation_status_at(int time);
|
||||||
int getCurrentTime();
|
int get_current_time();
|
||||||
void enqueueSlice (sgpem::SimulationStatus status);
|
void enqueue_slice(sgpem::SimulationStatus status);
|
||||||
void truncateAt (int instant);
|
void truncate_at(int instant);
|
||||||
|
|
||||||
static History& getInstance();
|
static History& getInstance();
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ namespace sgpem
|
||||||
std::vector<sgpem::Slice> _slices;
|
std::vector<sgpem::Slice> _slices;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}//~ namespace sgpem
|
||||||
|
|
||||||
#endif //HISTORY_H
|
#endif //HISTORY_H
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,8 @@ namespace sgpem
|
||||||
private:
|
private:
|
||||||
std::vector<Observer*> _attached;
|
std::vector<Observer*> _attached;
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
} //~ namespace sgpem
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -32,7 +32,7 @@ Process::~Process()
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::ustring
|
Glib::ustring
|
||||||
Process::getType() const
|
Process::get_type() const
|
||||||
{
|
{
|
||||||
return "Process";
|
return "Process";
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace sgpem
|
||||||
Process(const Glib::ustring& name, const unsigned int& arrival, const unsigned int& total, const int& priority);
|
Process(const Glib::ustring& name, const unsigned int& arrival, const unsigned int& total, const int& priority);
|
||||||
~Process();
|
~Process();
|
||||||
|
|
||||||
Glib::ustring getType() const;
|
Glib::ustring get_type() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,27 +35,27 @@ Schedulable::~Schedulable()
|
||||||
|
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
Schedulable::getArrivalTime() const
|
Schedulable::get_arrival_time() const
|
||||||
{
|
{
|
||||||
return _arrival_time;
|
return _arrival_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
Schedulable::getTotalCPUTime() const
|
Schedulable::get_total_cpu_time() const
|
||||||
{
|
{
|
||||||
return _total_time;
|
return _total_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
Schedulable::getPriority() const
|
Schedulable::get_priority() const
|
||||||
{
|
{
|
||||||
return _priority;
|
return _priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::ustring
|
Glib::ustring
|
||||||
Schedulable::getName() const
|
Schedulable::get_name() const
|
||||||
{
|
{
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,11 +42,11 @@ namespace sgpem
|
||||||
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 ~Schedulable() = 0;
|
||||||
|
|
||||||
virtual unsigned int getArrivalTime() const;
|
virtual unsigned int get_arrival_time() const;
|
||||||
unsigned int getTotalCPUTime() const;
|
unsigned int get_total_cpu_time() const;
|
||||||
int getPriority() const;
|
int get_priority() const;
|
||||||
Glib::ustring getName() const;
|
Glib::ustring get_name() const;
|
||||||
virtual Glib::ustring getType() const =0;
|
virtual Glib::ustring get_type() const = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Glib::ustring _name;
|
Glib::ustring _name;
|
||||||
|
|
|
@ -22,51 +22,51 @@
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
SchedulableStatus::SchedulableStatus(const Schedulable& obj):
|
SchedulableStatus::SchedulableStatus(const Schedulable& obj)
|
||||||
_ref(&obj), _last(-1), _timeLeft(obj.getTotalCPUTime()), _myState(state_future)
|
: _ref(&obj), _last(-1), _time_left(obj.get_total_cpu_time()), _my_state(state_future)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
SchedulableStatus::getCpuTimeLeft() const
|
SchedulableStatus::get_cpu_time_left() const
|
||||||
{
|
{
|
||||||
return _timeLeft;
|
return _time_left;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SchedulableStatus::giveCpuTime(const int& time)
|
SchedulableStatus::give_cpu_time(const int& time)
|
||||||
{
|
{
|
||||||
_timeLeft -= time;
|
_time_left -= time;
|
||||||
if (_timeLeft < 0)
|
if (_time_left < 0)
|
||||||
_timeLeft = 0;
|
_time_left = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SchedulableStatus::setLastScheduled(const int& time)
|
SchedulableStatus::set_last_scheduled(const int& time)
|
||||||
{
|
{
|
||||||
_last = time;
|
_last = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
SchedulableStatus::getLastScheduled() const
|
SchedulableStatus::get_last_scheduled() const
|
||||||
{
|
{
|
||||||
return _last;
|
return _last;
|
||||||
}
|
}
|
||||||
|
|
||||||
SchedulableStatus::state
|
SchedulableStatus::state
|
||||||
SchedulableStatus::getState() const
|
SchedulableStatus::get_state() const
|
||||||
{
|
{
|
||||||
return _myState;
|
return _my_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SchedulableStatus::setState(state s)
|
SchedulableStatus::set_state(state s)
|
||||||
{
|
{
|
||||||
_myState = s;
|
_my_state = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Schedulable*
|
const Schedulable*
|
||||||
SchedulableStatus::getSchedulable() const
|
SchedulableStatus::get_schedulable() const
|
||||||
{
|
{
|
||||||
return _ref;
|
return _ref;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ SchedulableStatus::getSchedulable() const
|
||||||
bool
|
bool
|
||||||
SchedulableStatus::operator==(const SchedulableStatus& dx) const
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,19 +53,19 @@ class SG_DLLEXPORT SchedulableStatus
|
||||||
//SchedulableStatus(const SchedulableStatus& obj); //copy constructor
|
//SchedulableStatus(const SchedulableStatus& obj); //copy constructor
|
||||||
bool operator==(const SchedulableStatus&) const;
|
bool operator==(const SchedulableStatus&) const;
|
||||||
|
|
||||||
int getCpuTimeLeft() const;
|
int get_cpu_time_left() const;
|
||||||
void giveCpuTime(const int& time);
|
void give_cpu_time(const int& time);
|
||||||
void setLastScheduled(const int& time);
|
void set_last_scheduled(const int& time);
|
||||||
int getLastScheduled() const;
|
int get_last_scheduled() const;
|
||||||
state getState() const;
|
state get_state() const;
|
||||||
void setState(state s);
|
void set_state(state s);
|
||||||
const Schedulable* getSchedulable() const;
|
const Schedulable* get_schedulable() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Schedulable* _ref;
|
const Schedulable* _ref;
|
||||||
int _last;
|
int _last;
|
||||||
int _timeLeft;
|
int _time_left;
|
||||||
state _myState;
|
state _my_state;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,10 @@ SimulationStatus::SimulationStatus(const SimulationStatus& dx)
|
||||||
Note that a copy of SchedulableStatus will be created
|
Note that a copy of SchedulableStatus will be created
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
SimulationStatus::setRunning(SchedulableStatus entity)
|
SimulationStatus::set_running(SchedulableStatus entity)
|
||||||
{
|
{
|
||||||
if (entity.getState() != SchedulableStatus::state_running)
|
if (entity.get_state() != SchedulableStatus::state_running)
|
||||||
entity.setState(SchedulableStatus::state_running);
|
entity.set_state(SchedulableStatus::state_running);
|
||||||
_set.push_back(entity);
|
_set.push_back(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,20 +57,20 @@ SimulationStatus::setRunning(SchedulableStatus entity)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
smart_ptr<SchedulableStatus>
|
smart_ptr<SchedulableStatus>
|
||||||
SimulationStatus::getRunning()
|
SimulationStatus::get_running()
|
||||||
{
|
{
|
||||||
for (list<SchedulableStatus>::iterator f=_set.begin(); f != _set.end(); f++)
|
for (list<SchedulableStatus>::iterator f=_set.begin(); f != _set.end(); f++)
|
||||||
if (f->getState() == SchedulableStatus::state_running){ //there can be only ONE running schedulable objext
|
if (f->get_state() == SchedulableStatus::state_running){ //there can be only ONE running schedulable objext
|
||||||
return smart_ptr<SchedulableStatus>(new SchedulableStatus(*f));
|
return smart_ptr<SchedulableStatus>(new SchedulableStatus(*f));
|
||||||
}
|
}
|
||||||
return smart_ptr<SchedulableStatus>(NULL);
|
return smart_ptr<SchedulableStatus>(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
smart_ptr<const SchedulableStatus>
|
smart_ptr<const SchedulableStatus>
|
||||||
SimulationStatus::getRunning() const
|
SimulationStatus::get_running() const
|
||||||
{
|
{
|
||||||
for (list<SchedulableStatus>::const_iterator f=_set.begin(); f != _set.end(); f++)
|
for (list<SchedulableStatus>::const_iterator f=_set.begin(); f != _set.end(); f++)
|
||||||
if (f->getState() == SchedulableStatus::state_running){ //there can be only ONE running schedulable objext
|
if (f->get_state() == SchedulableStatus::state_running){ //there can be only ONE running schedulable objext
|
||||||
return smart_ptr<const SchedulableStatus>(new SchedulableStatus(*f));
|
return smart_ptr<const SchedulableStatus>(new SchedulableStatus(*f));
|
||||||
}
|
}
|
||||||
return smart_ptr<const SchedulableStatus>(NULL); //NOT FOUND RUNNING ENTITIES
|
return smart_ptr<const SchedulableStatus>(NULL); //NOT FOUND RUNNING ENTITIES
|
||||||
|
@ -91,6 +91,5 @@ SimulationStatus::operator==(const SimulationStatus& dx) const
|
||||||
if (find(dx._set.begin(), dx._set.end(), *f) == dx._set.end()) //element NOT found!!
|
if (find(dx._set.begin(), dx._set.end(), *f) == dx._set.end()) //element NOT found!!
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,9 +44,11 @@ namespace sgpem
|
||||||
SimulationStatus(const SimulationStatus&);
|
SimulationStatus(const SimulationStatus&);
|
||||||
|
|
||||||
bool operator==(const SimulationStatus&) const;
|
bool operator==(const SimulationStatus&) const;
|
||||||
memory::smart_ptr<SchedulableStatus> getRunning(); //this method isn't const because it returns a pointer which CAN alter the object!
|
|
||||||
memory::smart_ptr<const SchedulableStatus> getRunning() const;
|
//this method isn't const because it returns a pointer which CAN alter the object!
|
||||||
void setRunning(SchedulableStatus);
|
memory::smart_ptr<SchedulableStatus> get_running();
|
||||||
|
memory::smart_ptr<const SchedulableStatus> get_running() const;
|
||||||
|
void set_running(SchedulableStatus);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//I used a list instead of a vector because this one could reallocate the internal elements
|
//I used a list instead of a vector because this one could reallocate the internal elements
|
||||||
|
|
|
@ -29,25 +29,25 @@ Slice::Slice(const int& start, const int& duration, const SimulationStatus& stat
|
||||||
}
|
}
|
||||||
|
|
||||||
SimulationStatus&
|
SimulationStatus&
|
||||||
Slice::getSimulationStatus()
|
Slice::get_simulation_status()
|
||||||
{
|
{
|
||||||
return _ref;
|
return _ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Slice::getStartedAt() const
|
Slice::get_started_at() const
|
||||||
{
|
{
|
||||||
return _started_at;
|
return _started_at;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Slice::getDuration() const
|
Slice::get_duration() const
|
||||||
{
|
{
|
||||||
return _duration;
|
return _duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Slice::setDuration(const int& i)
|
Slice::set_duration(const int& i)
|
||||||
{
|
{
|
||||||
_duration = i;
|
_duration = i;
|
||||||
}
|
}
|
|
@ -41,10 +41,10 @@ namespace sgpem
|
||||||
public:
|
public:
|
||||||
Slice(const int& start, const int& duration, const SimulationStatus& status);
|
Slice(const int& start, const int& duration, const SimulationStatus& status);
|
||||||
|
|
||||||
SimulationStatus& getSimulationStatus();
|
SimulationStatus& get_simulation_status();
|
||||||
int getStartedAt() const;
|
int get_started_at() const;
|
||||||
int getDuration() const;
|
int get_duration() const;
|
||||||
void setDuration(const int&);
|
void set_duration(const int&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SimulationStatus _ref;
|
SimulationStatus _ref;
|
||||||
|
@ -52,6 +52,6 @@ namespace sgpem
|
||||||
int _duration;
|
int _duration;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} //~ namespace sgpem
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -27,15 +27,13 @@
|
||||||
#include <gtkmm/textview.h>
|
#include <gtkmm/textview.h>
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
|
|
||||||
GraphicalTerminalIO::GraphicalTerminalIO()
|
using namespace sgpem;
|
||||||
{
|
|
||||||
|
|
||||||
}
|
GraphicalTerminalIO::GraphicalTerminalIO()
|
||||||
|
{}
|
||||||
|
|
||||||
GraphicalTerminalIO::~GraphicalTerminalIO()
|
GraphicalTerminalIO::~GraphicalTerminalIO()
|
||||||
{
|
{}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GraphicalTerminalIO::size_type
|
GraphicalTerminalIO::size_type
|
||||||
GraphicalTerminalIO::write_buffer(const Glib::ustring& buffer)
|
GraphicalTerminalIO::write_buffer(const Glib::ustring& buffer)
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
#include "iomanager.hh"
|
#include "iomanager.hh"
|
||||||
|
|
||||||
|
namespace sgpem {
|
||||||
|
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
|
|
||||||
class GraphicalTerminalIO;
|
class GraphicalTerminalIO;
|
||||||
|
@ -40,7 +42,8 @@ class GraphicalTerminalIO;
|
||||||
/** \brief
|
/** \brief
|
||||||
*
|
*
|
||||||
* ... long desc ... */
|
* ... long desc ... */
|
||||||
class GraphicalTerminalIO : public IOManager, public Gtk::VBox {
|
class GraphicalTerminalIO : public IOManager, public Gtk::VBox
|
||||||
|
{
|
||||||
typedef unsigned int size_type;
|
typedef unsigned int size_type;
|
||||||
public:
|
public:
|
||||||
GraphicalTerminalIO();
|
GraphicalTerminalIO();
|
||||||
|
@ -53,4 +56,6 @@ private:
|
||||||
Gtk::Entry text_input;
|
Gtk::Entry text_input;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
|
|
||||||
|
namespace sgpem {
|
||||||
|
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
|
|
||||||
class IOManager;
|
class IOManager;
|
||||||
|
@ -35,7 +37,8 @@ class IOManager;
|
||||||
/** \brief
|
/** \brief
|
||||||
*
|
*
|
||||||
* ... long desc ... */
|
* ... long desc ... */
|
||||||
class IOManager {
|
class IOManager
|
||||||
|
{
|
||||||
typedef unsigned int size_type;
|
typedef unsigned int size_type;
|
||||||
public:
|
public:
|
||||||
virtual ~IOManager() {}
|
virtual ~IOManager() {}
|
||||||
|
@ -44,4 +47,6 @@ public:
|
||||||
virtual size_type read_command(Glib::ustring& buffer) const = 0;
|
virtual size_type read_command(Glib::ustring& buffer) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
60
src/main.cc
60
src/main.cc
|
@ -44,7 +44,7 @@
|
||||||
int
|
int
|
||||||
main(int argc, char* argv[])
|
main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
using namespace sgpem;
|
||||||
|
|
||||||
// Set up gettext support
|
// Set up gettext support
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
|
@ -73,45 +73,45 @@ main(int argc, char* argv[])
|
||||||
SchedulableStatus ss2(p2);
|
SchedulableStatus ss2(p2);
|
||||||
SchedulableStatus ss3(p3);
|
SchedulableStatus ss3(p3);
|
||||||
|
|
||||||
SimulationStatus sim1; sim1.setRunning(p1);
|
SimulationStatus sim1; sim1.set_running(p1);
|
||||||
SimulationStatus sim2; sim2.setRunning(p2);
|
SimulationStatus sim2; sim2.set_running(p2);
|
||||||
SimulationStatus sim3; sim3.setRunning(p3);
|
SimulationStatus sim3; sim3.set_running(p3);
|
||||||
|
|
||||||
History h(History::getInstance());
|
History h(History::getInstance());
|
||||||
|
|
||||||
h.enqueueSlice(sim1);
|
h.enqueue_slice(sim1);
|
||||||
h.enqueueSlice(sim1);
|
h.enqueue_slice(sim1);
|
||||||
h.enqueueSlice(sim2);
|
h.enqueue_slice(sim2);
|
||||||
h.enqueueSlice(sim1);
|
h.enqueue_slice(sim1);
|
||||||
h.enqueueSlice(sim2);
|
h.enqueue_slice(sim2);
|
||||||
h.enqueueSlice(sim1);
|
h.enqueue_slice(sim1);
|
||||||
h.enqueueSlice(sim2);
|
h.enqueue_slice(sim2);
|
||||||
h.enqueueSlice(sim3);
|
h.enqueue_slice(sim3);
|
||||||
h.enqueueSlice(sim3);
|
h.enqueue_slice(sim3);
|
||||||
h.enqueueSlice(sim1);
|
h.enqueue_slice(sim1);
|
||||||
h.enqueueSlice(sim3);
|
h.enqueue_slice(sim3);
|
||||||
h.enqueueSlice(sim1);
|
h.enqueue_slice(sim1);
|
||||||
|
|
||||||
h.truncateAt(3);
|
h.truncate_at(3);
|
||||||
|
|
||||||
smart_ptr<const sgpem::SimulationStatus> quale;
|
smart_ptr<const sgpem::SimulationStatus> quale;
|
||||||
|
|
||||||
quale = h.getSimulationStatusAt(0);
|
quale = h.get_simulation_status_at(0);
|
||||||
if (quale) cout << "\n" << quale->getRunning()->getSchedulable()->getName(); else cout << "NO";
|
if (quale) cout << "\n" << quale->get_running()->get_schedulable()->get_name(); else cout << "NO";
|
||||||
quale = h.getSimulationStatusAt(1);
|
quale = h.get_simulation_status_at(1);
|
||||||
if (quale) cout << "\n" << quale->getRunning()->getSchedulable()->getName(); else cout << "NO";
|
if (quale) cout << "\n" << quale->get_running()->get_schedulable()->get_name(); else cout << "NO";
|
||||||
quale = h.getSimulationStatusAt(2);
|
quale = h.get_simulation_status_at(2);
|
||||||
if (quale) cout << "\n" << quale->getRunning()->getSchedulable()->getName(); else cout << "NO";
|
if (quale) cout << "\n" << quale->get_running()->get_schedulable()->get_name(); else cout << "NO";
|
||||||
|
|
||||||
h.truncateAt(2);
|
h.truncate_at(2);
|
||||||
|
|
||||||
smart_ptr<const sgpem::SchedulableStatus> quale2;
|
smart_ptr<const sgpem::SchedulableStatus> quale2;
|
||||||
quale2 = h.getScheduledAt(0);
|
quale2 = h.get_scheduled_at(0);
|
||||||
if (quale2) cout << "\n" << quale2->getSchedulable()->getName(); else cout << "NO";
|
if (quale2) cout << "\n" << quale2->get_schedulable()->get_name(); else cout << "NO";
|
||||||
quale2 = h.getScheduledAt(1);
|
quale2 = h.get_scheduled_at(1);
|
||||||
if (quale2) cout << "\n" << quale2->getSchedulable()->getName(); else cout << "NO";
|
if (quale2) cout << "\n" << quale2->get_schedulable()->get_name(); else cout << "NO";
|
||||||
quale2 = h.getScheduledAt(2);
|
quale2 = h.get_scheduled_at(2);
|
||||||
if (quale2) cout << "\n" << quale2->getSchedulable()->getName(); else cout << "NO";
|
if (quale2) cout << "\n" << quale2->get_schedulable()->get_name(); else cout << "NO";
|
||||||
|
|
||||||
|
|
||||||
cout << "\n\n";
|
cout << "\n\n";
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#include <gtkmm/menubar.h>
|
#include <gtkmm/menubar.h>
|
||||||
#include <gtkmm/window.h>
|
#include <gtkmm/window.h>
|
||||||
|
|
||||||
|
using namespace sgpem;
|
||||||
|
|
||||||
MainWindow::MainWindow()
|
MainWindow::MainWindow()
|
||||||
{
|
{
|
||||||
set_title(PACKAGE_STRING);
|
set_title(PACKAGE_STRING);
|
||||||
|
|
|
@ -18,14 +18,16 @@
|
||||||
// along with SGPEMv2; if not, write to the Free Software
|
// along with SGPEMv2; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#ifndef GTKGUI_MAINWINDOW_HH
|
#ifndef MAINWINDOW_HH
|
||||||
#define GTKGUI_MAINWINDOW_HH 1
|
#define MAINWINDOW_HH 1
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
|
|
||||||
#include <gtkmm/window.h>
|
#include <gtkmm/window.h>
|
||||||
|
|
||||||
|
namespace sgpem {
|
||||||
|
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
|
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
|
@ -36,7 +38,8 @@ class MainWindow;
|
||||||
*
|
*
|
||||||
* This is the main simulation window displayed
|
* This is the main simulation window displayed
|
||||||
* when the program is run with a GUI */
|
* when the program is run with a GUI */
|
||||||
class MainWindow : public Gtk::Window {
|
class MainWindow : public Gtk::Window
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
MainWindow();
|
MainWindow();
|
||||||
virtual ~MainWindow();
|
virtual ~MainWindow();
|
||||||
|
@ -45,4 +48,6 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} //~ namespace sgpem
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,12 +25,15 @@
|
||||||
|
|
||||||
namespace sgpem
|
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 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
|
class SG_DLLEXPORT Observer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -30,6 +30,6 @@ void
|
||||||
start_gui(int argc, char** argv)
|
start_gui(int argc, char** argv)
|
||||||
{
|
{
|
||||||
Gtk::Main gtk_main(argc,argv);
|
Gtk::Main gtk_main(argc,argv);
|
||||||
MainWindow main_window;
|
sgpem::MainWindow main_window;
|
||||||
Gtk::Main::run(main_window);
|
Gtk::Main::run(main_window);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue