-changing SchedulableList to SchedulableQueue: intermediate commit,

so SVN can let me use "mv"

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@602 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
elvez 2006-06-03 14:40:19 +00:00
parent 16acaf51d9
commit 4508ed017b
16 changed files with 70 additions and 70 deletions

View file

@ -47,7 +47,7 @@ History::get_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 there are no running entities in the associated
SchedulableList
SchedulableQueue
*/
smart_ptr<SchedulableStatus>
History::get_scheduled_at(int time) const
@ -56,7 +56,7 @@ History::get_scheduled_at(int time) const
return smart_ptr<SchedulableStatus>(NULL);
//look for a runing entity
smart_ptr<SchedulableList> p = get_simulation_status_at(time);
smart_ptr<SchedulableQueue> p = get_simulation_status_at(time);
for (uint i = 0; i < p->size(); i++)
if (p->get_item_at(i)->get_state() == SchedulableStatus::state_running)
@ -69,21 +69,21 @@ History::get_scheduled_at(int time) const
Returns a pointer to a copy of the SimulationStatus object relative to this instant or NULL
if time is out of range.
*/
smart_ptr<SchedulableList>
smart_ptr<SchedulableQueue>
History::get_simulation_status_at(int time) const
{
if (time > _total_time_elapsed || time < 0) //out of range
return smart_ptr<SchedulableList>(NULL);
return smart_ptr<SchedulableQueue>(NULL);
int trascorso = -1;
for(vector<Slice>::const_iterator i=_slices.begin(); i < _slices.end(); i++)
if (time <= trascorso + i->get_duration()) //FOUND!!
return smart_ptr<SchedulableList>(new SchedulableList(*i->get_simulation_status()));
return smart_ptr<SchedulableQueue>(new SchedulableQueue(*i->get_simulation_status()));
else //Go on...
trascorso += i->get_duration();
//never reached if all slices are CONTIGUOUS (ans THIS shoul be!!)!!!
return smart_ptr<SchedulableList>(NULL);
return smart_ptr<SchedulableQueue>(NULL);
}
int
@ -97,7 +97,7 @@ History::get_current_time() const
Calls the method notify() in quality of ObservedSubject, updating all observers.
*/
void
History::enqueue_slice(const SchedulableList& status)
History::enqueue_slice(const SchedulableQueue& status)
{
if(_slices.size() == 0)
{

View file

@ -62,7 +62,7 @@ namespace sgpem
\param time The inquired time instant.
\return The list of Schedulable status objects at the specified time.
*/
virtual memory::smart_ptr<sgpem::SchedulableList> get_simulation_status_at(int time) const;
virtual memory::smart_ptr<sgpem::SchedulableQueue> get_simulation_status_at(int time) const;
/**
Gets the current time.
@ -74,7 +74,7 @@ namespace sgpem
Sets the status of simulation at the current time.
\param status The list of \ref Schedulable status objects at the current time.
*/
virtual void enqueue_slice(const sgpem::SchedulableList& status);
virtual void enqueue_slice(const sgpem::SchedulableQueue& status);
/**
Remove all data in History following the specified time.

View file

@ -24,12 +24,12 @@ using namespace sgpem;
using namespace std;
using namespace memory;
SchedulableList::SchedulableList()
SchedulableQueue::SchedulableQueue()
{
}
SchedulableStatus*
SchedulableList::top()
SchedulableQueue::top()
{
if (_list.size() == 0)
return NULL;
@ -37,7 +37,7 @@ SchedulableList::top()
}
SchedulableStatus*
SchedulableList::bottom()
SchedulableQueue::bottom()
{
if (_list.size() == 0)
return NULL;
@ -51,7 +51,7 @@ SchedulableList::bottom()
DON'T call delete on the returned pointer! Its destruction is managed by the queue.
*/
SchedulableStatus*
SchedulableList::get_item_at(const uint& where)
SchedulableQueue::get_item_at(const uint& where)
{
if (_list.size() == 0 || where >= _list.size())
return NULL;
@ -63,7 +63,7 @@ SchedulableList::get_item_at(const uint& where)
}
const SchedulableStatus*
SchedulableList::get_item_at(const uint& where) const
SchedulableQueue::get_item_at(const uint& where) const
{
if (_list.size() == 0 || where >= _list.size())
return NULL;
@ -79,25 +79,25 @@ SchedulableList::get_item_at(const uint& where) const
*/
uint
SchedulableList::size() const
SchedulableQueue::size() const
{
return _list.size();
}
void
SchedulableList::add_at_top(const SchedulableStatus& ss)
SchedulableQueue::add_at_top(const SchedulableStatus& ss)
{
_list.push_front(ss);
}
void
SchedulableList::add_at_bottom(const SchedulableStatus& ss)
SchedulableQueue::add_at_bottom(const SchedulableStatus& ss)
{
_list.push_back(ss);
}
smart_ptr<SchedulableStatus>
SchedulableList::remove(const uint& position)
SchedulableQueue::remove(const uint& position)
{
if (_list.size() == 0 || position >= _list.size())
return smart_ptr<SchedulableStatus>(NULL);
@ -114,7 +114,7 @@ SchedulableList::remove(const uint& position)
*/
bool
SchedulableList::insert_at(const uint& which, const uint& where)
SchedulableQueue::insert_at(const uint& which, const uint& where)
{
//out of range
if (which >= _list.size() || where >= _list.size())
@ -144,7 +144,7 @@ SchedulableList::insert_at(const uint& which, const uint& where)
*/
void
SchedulableList::clear()
SchedulableQueue::clear()
{
_list.clear();
}
@ -154,7 +154,7 @@ SchedulableList::clear()
\brief Returns TRUE if the two objects have the same SchedulableStatus objects in the same order.
*/
bool
SchedulableList::operator==(const SchedulableList& dx) const
SchedulableQueue::operator==(const SchedulableQueue& dx) const
{
return _list == dx._list;
}
@ -164,7 +164,7 @@ SchedulableList::operator==(const SchedulableList& dx) const
\brief Returns TRUE if the two objects have the same SchedulableStatus objects with NO ORDER IMPORTANCE.
*/
bool
SchedulableList::has_same_objects(const SchedulableList& dx) const
SchedulableQueue::has_same_objects(const SchedulableQueue& dx) const
{
if (_list.size() != dx._list.size())
return false;
@ -179,7 +179,7 @@ SchedulableList::has_same_objects(const SchedulableList& dx) const
void
SchedulableList::swap(unsigned int positionA, unsigned int positionB) throw()
SchedulableQueue::swap(unsigned int positionA, unsigned int positionB) throw()
{
if (positionA == positionB || positionA >= _list.size() || positionB >= _list.size())
return;

View file

@ -31,14 +31,14 @@
namespace sgpem
{
class SchedulableList;
class SchedulableQueue;
class SG_DLLEXPORT SchedulableList
class SG_DLLEXPORT SchedulableQueue
{
public:
SchedulableList();
bool operator==(const SchedulableList&) const;
bool has_same_objects(const SchedulableList& dx) const;
SchedulableQueue();
bool operator==(const SchedulableQueue&) const;
bool has_same_objects(const SchedulableQueue& dx) const;
/** \brief Returns a pointer to the first element
*

View file

@ -46,7 +46,7 @@ Scheduler::get_instance()
return *_instance;
}
SchedulableList*
SchedulableQueue*
Scheduler::get_ready_queue()
{
return &_ready_queue;
@ -90,7 +90,7 @@ Scheduler::step_forward() throw(UserInterruptException)
//******************
//check for arrivals and prepare the queue
//******************
smart_ptr<SchedulableList> initial = h.get_simulation_status_at(h.get_current_time());
smart_ptr<SchedulableQueue> initial = h.get_simulation_status_at(h.get_current_time());
if (!initial)
{
cout << _("\nNo initial state inserted!!\n");

View file

@ -87,13 +87,13 @@ namespace sgpem
\return a pointer to the queue containing all the ready
schedulable objects (for the policy to sort it).
*/
SchedulableList* get_ready_queue();
SchedulableQueue* get_ready_queue();
/**
Resets the simulation to the initial state.
*/
void reset_status();
/**
Generates a new SchedulableList representing the status of the processes
Generates a new SchedulableQueue representing the status of the processes
at the simulation instant next to the current one, and extends the History by
one instant with it.
*/
@ -115,7 +115,7 @@ namespace sgpem
private:
Scheduler(); //private constructor.
static Scheduler* _instance;
SchedulableList _ready_queue;
SchedulableQueue _ready_queue;
PolicyManager& _policy_manager;
};

View file

@ -23,12 +23,12 @@ using namespace sgpem;
using namespace std;
Slice::Slice(const int& start, const int& duration, const SchedulableList& status)
Slice::Slice(const int& start, const int& duration, const SchedulableQueue& status)
: _ref(status), _started_at(start), _duration(duration)
{
}
const SchedulableList*
const SchedulableQueue*
Slice::get_simulation_status() const
{
return &_ref;

View file

@ -45,13 +45,13 @@ namespace sgpem
\param duration Time length of Slice.
\param status Photoshot of all \ref Schedulable during this Slice.
*/
Slice(const int& start, const int& duration, const SchedulableList& status);
Slice(const int& start, const int& duration, const SchedulableQueue& status);
/**
Gets a constant reference to the \ref SchedulableList object for this Slice.
\return The reference (constant) to the SchedulableList object for this Slice.
Gets a constant reference to the \ref SchedulableQueue object for this Slice.
\return The reference (constant) to the SchedulableQueue object for this Slice.
*/
const SchedulableList* get_simulation_status() const;
const SchedulableQueue* get_simulation_status() const;
/**
@ -73,7 +73,7 @@ namespace sgpem
void set_duration(const int& duration);
private:
SchedulableList _ref;
SchedulableQueue _ref;
int _started_at;
int _duration;
};