/*
 $Id: statistic.cc,v 1.1.1.1 1996/10/02 10:35:45 roitzsch Exp $
 (C)opyright 1996 by Konrad-Zuse-Center, Berlin
 All rights reserved.
 Part of the Kaskade distribution
*/

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <math.h>

#include "cmdpars.h"
extern CmdPars  Cmd;

#include "statistic.h"

Statistic:: Statistic() 
{
    active= False;	
    if ( Cmd.isTrue("writeStatistics"))  
    {
	active = True;

	idRefStep = ZD_DataDef("refStep",0);
	idDepth   = ZD_DataDef("depth",0);
	idNodes   = ZD_DataDef("nodes",0);
	idDiscErr = ZD_DataDef("error",0);
	idIteSteps= ZD_DataDef("iteSteps",idRefStep);
	idIteErr  = ZD_DataDef("iteErr",idRefStep);
    }
}


Statistic:: ~Statistic() 
{ 
}


//-------------------------------------------------------------------------

ZD_DataDesc Statistic:: ZD_DataDef(const char *name,ZD_DataDesc dep)
{
	char *namecopy;
	int lenght;
	dataDescimpl *datadesc;

	if (name==0) return 0;
	lenght=strlen(name);
	namecopy=(char*)malloc(lenght*sizeof(char));
	strcpy(namecopy,name);
	datadesc=(dataDescimpl*)malloc(sizeof(dataDescimpl));
	datadesc->name=namecopy;
	datadesc->older=dep;
	printf("\n$ZDDefine %s ",datadesc->name);
	if (datadesc->older==0) 
	{
	printf("\n");
	return (datadesc);
	}
	else
	printf("%s\n",datadesc->older->name);
	return (datadesc);
}

void Statistic:: ZD_IntWrite(ZD_DataDesc desc,int data)
{
	if (desc==0) return;

	printf("\n$ZDData %s %i\n",desc->name,data);
}

void Statistic:: ZD_RealWrite(ZD_DataDesc desc,double data)
{
	if (desc==0) return;

	printf("\n$ZDData %s %f\n",desc->name,data);
}

//-------------------------------------------------------------------------





