sgpemv2/src/backend/history.hh
tchernobog 759b90b017 - Substitute the old SchedulableQueue with the new ReadyQueue
- Add interfaces for Process and Thread into the "sgpem.i" SWIG
interface file, change DynamicSchedulable into Schedulable
- Add dynamic_cast for the return value of ReadyQueue::get_item_at()
into the pyloader "sgpem.i" SWIG interface, so that a Schedulable
can be either recognized as a Thread or a Process
- TODO: wrap STL exceptions in SWIG interface
- Please note that code won't compile until the new History and
Scheduler::step_forward() will be in place. This is a known issue.


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@689 3ecf2c5c-341e-0410-92b4-d18e462d057c
2006-07-02 13:51:03 +00:00

105 lines
3.1 KiB
C++

// src/backend/history.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef HISTORY_HH
#define HISTORY_HH 1
#include "config.h"
#include <vector>
#include <iostream>
#include "slice.hh"
#include "observed_subject.hh"
#include "ready_queue.hh"
#include "dynamic_schedulable.hh"
#include "smartp.hh"
// Do not include complete template definition here:
#include "singleton.hh"
namespace sgpem
{
/** \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.
In particoular it's possible to know which entity was running at a precise moment.
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 SG_DLLEXPORT History : public Singleton<History>, public ObservedSubject
{
friend class Singleton<History>;
public:
/**
Gets the \ref Schedulable object running at the specified time.
\param time The inquired time instant.
\return The Schedulable object running at the given time.
*/
virtual memory::smart_ptr<sgpem::DynamicSchedulable> get_scheduled_at(int time) const;
/**
Gets the status of simulation at the specified time.
\param time The inquired time instant.
\return The list of Schedulable status objects at the specified time.
*/
virtual memory::smart_ptr<sgpem::ReadyQueue> get_simulation_status_at(int time) const;
/**
Gets the current time.
\return The current history time.
*/
virtual int get_current_time() const;
/**
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::ReadyQueue& status);
/**
Remove all data in History following the specified time.
\param instant Desired cutting time.
*/
virtual void truncate_at(int instant);
protected:
History(); //private constructor.
History(const History&);
History& operator=(const History&);
private:
int _total_time_elapsed;
std::vector<sgpem::Slice> _slices;
};
}//~ namespace sgpem
#endif //HISTORY_H