/***************************************************************************
 *   Copyright (C) 2006 by Miguel Armando Riem de Oliveira   *
 *   mike@BlackBandit   *
 *                                                                         *
 *   This program 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 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program 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 this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef _TIMER_H_
#define _TIMER_H_

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdio.h>
#include <stdlib.h>


#include </usr/include/opencv/cxcore.h>
//#include <cxcore.h>
//you have to have the path to cxcore in the directory where this one is called
//changed again just to cxcore when i went to ubuntu. lets see if it works.

#define MAXNUMBEROFTICKS 10

enum{
	SECONDS = 77,
	TENTHSOFSECONDS,
	HUNDREDSOFSECONDS,
	MILISECONDS,
	MICROSECONDS
	};

class timer{
public:
	timer();
	~timer();

	int Tic(unsigned char n=0);
	int Toc(unsigned char n=0, int units = MILISECONDS);

private:
	
	struct {double Second; 		//!< Tickspermicrosec the amount of ticks that ocour in a second.
		double MiliSecond;	//!< Tickspermicrosec the amount of ticks that ocour in a milisecond.
		double MicroSecond;	//!< Tickspermicrosec the amount of ticks that ocour in a microsecond.
		}Ticksper;

	int64 TicTick[MAXNUMBEROFTICKS],TocTick[MAXNUMBEROFTICKS];
	int updatetick(int64 *t){return *t=cvGetTickCount();};	
};
#endif
