// src/backend/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 STATISTICS_HH
#define STATISTICS_HH 1

#include <sgpemv2/sgpemv2-visibility.hh>
#include <sgpemv2/templates/singleton.hh>
#include <sgpemv2/process_statistics.hh>
#include <sgpemv2/simulation_statistics.hh>
#include <vector>

#include <glibmm/ustring.h>

namespace sgpem
{
	/**		\brief Permits to retrieve the statistics of the current Simulation
	
	Permits to retrieve informations about all schedulables and the simulation 
	at a precise moment in the history
	
	*/
	class Statistics;
	class ConcreteStatistics;

	class SG_DLLEXPORT Statistics  : public Singleton<ConcreteStatistics>
	{
	public:		
		virtual ~Statistics() = 0;
		static Statistics& get_instance();		
		
		/**		\brief Calculates the statistics
		Calculates the statistics until the specified instant which must be equal to
		or smaller than the current time. This method executes all calculations which
		can be expensive for the CPU. Each call to this method erases all previously 
		calculated statistics.
		
		\param instant 	The instant until which the History will be examinated to 
							calculate the statistics
		*/
		virtual void									calculateStatisticsAt(const int& instant) = 0;
		
		/**	
		\brief Returns all processes statistics
					   
		Returns a copy of all statistics calculated with calculateStatisticsAt() referred
		to all processes of the environment. If calculateStatisticsAt() has never been
		called before this call then nullptr will be returned.
		
		\returns a vector filled with copies of the ProcessStatistics calculated by calculateStatisticsAt()
					   
		*/
		virtual std::vector<const ProcessStatistics*>	get_process_statistics() const = 0;
			   
		/**	
		\brief Returns the simulation statistics
		
		Returns a pointer to the statistics of the simulation referred to the instant specified with
		"calculateStatisticsAt()". If calculateStatisticsAt() has never been called before this call
		then the nullptr pointer will be returned.

	   \attention Don't delete() the returned pointer: this will bring to memory corruption!
		\returns a pointer to the internal SimulationStatistics object updated by calculateStatisticsAt()
		\returns the nullptr pointer if calculateStatisticsAt() has never been called
		
		*/
		virtual const SimulationStatistics*			get_simulation_statistics() const = 0;
 
	protected:
	
		Statistics(); // Constructor

	};
}

#endif


