#ifndef LOGOUTPUT_H
#define LOGOUTPUT_H

#include "output.h"
#include "../micro.h"
#include "../microadam.h"
#include "../microeva.h"
#include <fstream>

extern "C"
{
  #include <opencv/highgui.h>
}

using namespace std;

namespace seemicro
{

class LogOutput : public OutputModule
{
  Micro *micro;
  ofstream outf;
  int frameno;
public:
  LogOutput(Micro *Am, string filename) : micro(Am)
  {
    cerr << "Loggging to '" << filename << "'.\n";
    outf.open(filename.c_str());
    frameno = 0;
  };

  void output(bool keyframe)
  {
    // framenummer, (zeit), parameter
    outf << "frame=" << frameno++
	 << " mittevalid=" << micro->mitteValid
         << " mitte=" << micro->mitte
	 << " radiusvalid=" << micro->radiusValid
	 << " radius=" << micro->radius
	 << " alphavalid=" << micro->alphaValid
	 << " alpha=" << micro->alpha;
    MicroAdam *adam = dynamic_cast<MicroAdam*>(micro);
    if(adam)
    {
      outf << " beta=" << adam->beta;
    }
    else if(MicroEva *eva = dynamic_cast<MicroEva*>(micro))
    {
      for(int i=0;i<=4; i++)
        outf << " beta" << i << "=" << eva->beta[i];
    }
    outf << endl;
  }

};

} // seemicro

#endif
