// src/backend/schedulable_statistics.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 3 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, see http://www.gnu.org/licenses/.


#ifndef SCHEDULABLE_STATISTICS_HH
#define SCHEDULABLE_STATISTICS_HH 1

#include <sgpemv2/sgpemv2-visibility.hh>

#include "schedulable.hh"
#include <glibmm/ustring.h>


namespace sgpem
{
	/**	\brief Represents the statistics of a Schedulable

		Represents the statistics of a Schedulable. This class is created by "Statistics" class
		and presents only "getters" methods which execute no calculations: they only return the
		internal results calulated at construction time. To retrieve these results the whole History
		(until the instant specified through Statistics::calculateStatisticsAt(int)) is scanned.
	*/
	class SchedulableStatistics
	{
		public:
			virtual ~SchedulableStatistics();

			/**	\brief Returns the total execution time
				\returns the number of instants during which the state of the schedulable was "running"
			*/
			virtual int	get_execution_time() const =0;

			/**	\brief Returns the percentage of the execution
				\returns 	the number of instants during which the state of the schedulable was "running"
							divided by the total running time of the schedulable
			*/
			virtual int	get_execution_progress() const =0;

			/**	\brief Returns the total incativity time
				\returns the number of instants during which the state of the schedulable was "ready" or "blocked"
			*/
			virtual int	get_total_inactivity() const =0;

			/**	\brief Returns the response time of the schedulable
				\returns the number of instants during which the state of the schedulable was "ready" or "blocked"
							before the first execution instant
			*/
			virtual int	get_response_time() const =0;

			/**	\brief Returns the turn-around time of the schedulable
				\returns the number of instants during which the state of the schedulable was "ready" or "blocked"
							or "running"
			*/
			virtual int	get_turn_around() const =0;

			/**	\brief Returns the percentage of the execution efficiency
				\returns The percentage of the efficiency. This value is calucated this way: turn_around/execution_time
			*/
			virtual int	get_efficiency() const =0;

			/**	\brief Returns the resources usage time of the schedulable
				\returns the number of instants during which the the schedulable used a resource. If the schedulable
				used more than one resource a time then this value is increased accordingly.
			*/
			virtual int	get_resource_usage_time() const =0;

			/**	\brief Returns the number of instants this schedulable was waiting for a resource to be allocable
				\returns the number of instants during which the state of the schedulable was "blocked"
			*/
			virtual int	get_resource_waitings_time() const =0;

			/**	\brief Returns the Schedulable object these statistics refer to
				\returns Returns a const pointer to the Schedulable object these statistics refer to
			*/
			virtual const Schedulable*		get_core() const =0;

		protected:

			SchedulableStatistics();

			int				_execution_time;
			int				_execution_progress;
			int				_total_inactivity;
			int				_response_time;
			int				_turn_around;
			int				_efficiency;
			int				_resource_usage_time;
			int				_resource_waitings_time;
	};
}

#endif
