sgpemv2/src/backend/history.hh
tchernobog 9856a86c87 - Start implementing Scheduler::step_forward(). Whoohooo!
- Changed Schedulable::get_remaining_time() in get_elapsed_time()


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@702 3ecf2c5c-341e-0410-92b4-d18e462d057c
2006-07-03 21:55:09 +00:00

118 lines
3.7 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 "environment.hh"
#include <glibmm/ustring.h>
#include <stdexcept>
#include <utility>
#include <vector>
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;
// Forward declarations:
class HistoryObserver;
class Resource;
class Process;
class Thread;
class Request;
class SubRequest;
class SG_DLLEXPORT History
{
public:
typedef unsigned int size_t;
typedef unsigned int time_t;
typedef unsigned int position;
typedef int prio_t;
typedef Environment::resource_key_t resource_key_t;
typedef const std::pair<resource_key_t, Resource*> ResourcePair;
virtual ~History() = 0;
virtual size_t get_size() = 0;
virtual const Environment& get_last_environment() const = 0;
virtual const Environment& get_environment_at(position index) const throw(std::out_of_range) = 0;
virtual void remove(resource_key_t resource_key) = 0;
virtual void remove(Process& process) = 0;
virtual void remove(Thread& thread) = 0;
virtual void remove(Request& request) = 0;
virtual void remove(SubRequest& subrequest) = 0;
virtual ResourcePair add_resource(const Glib::ustring& name,
bool preemptable = false,
size_t places = 1,
size_t availability = 0) = 0;
virtual Process& add_process(const Glib::ustring& name,
time_t arrival_time,
prio_t base_priority = 0) = 0;
virtual Thread& add_thread(const Glib::ustring& name,
Process& parent,
time_t cpu_time,
time_t arrival_time = 0,
prio_t base_priority = 0) = 0;
virtual Request& add_request(Thread& owner,
time_t instant) = 0;
virtual SubRequest& add_subrequest(Request& request,
resource_key_t resource_key,
time_t duration,
size_t places = 1) = 0;
virtual void attach(HistoryObserver& observer);
virtual void detach(const HistoryObserver& observer);
protected:
typedef std::vector<HistoryObserver*> RegisteredObservers;
RegisteredObservers _observers;
virtual void notify_change();
}; //~ class History
}//~ namespace sgpem
#endif //~ HISTORY_HH