#ifdef STATISTICS

/*
 * $Id$
 *
 * [ Description ]
 * 
 */

#include "Behavioural/include/Statistics.h"
#include <time.h>
#include <sstream>
#include <fstream>
using namespace std;

namespace morpheo              {
namespace behavioural          {

  void Statistics::generate_file(string stat)
  {
    ostringstream filename;
    filename << _name << ".stat";

    cout << "Generate file \""<< filename.str() << "\"" << endl;

    ofstream file;
    file.open(filename.str().c_str(),ios::out | ios::trunc);

    time_t current_time;
    time (&current_time);

    // print header
    file << "<!-- "                                                    << endl
	 << "\tfile        : " << filename.str()                       << endl
	 << "\tdate        : " << ctime (&current_time )
	 << "\tcomment     : it's a autogenerated file : don't modify" << endl
	 << "-->"                                                      << endl
	 <<                                                               endl;
	 
    file << stat;
    
    file.close();
  }

  void Statistics::generate_file(void)
  {
    generate_file(print(0));
  };

}; // end namespace behavioural          
}; // end namespace morpheo              

#endif
