/***************************************************************************
 *   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_CPP_
#define _TIMER_CPP_

#include <timer.h>

timer::timer()
{
	Ticksper.MicroSecond = cvGetTickFrequency();
	Ticksper.MiliSecond = Ticksper.MicroSecond * 1000;
	Ticksper.Second = Ticksper.MicroSecond * 1000000;
};

timer::~timer()
{




};

int timer::Toc(unsigned char n, int units)
{
int64 passedticks;
	if (n<MAXNUMBEROFTICKS)
	{
		updatetick(&TocTick[n]);
		passedticks = TocTick[n] - TicTick[n];
	}
	else return -1;

	switch (units)
	{
		case MILISECONDS:
		{
			return (int) ((passedticks)/(Ticksper.MiliSecond));
		break;
		}
		case SECONDS:
		{
			return (int) ((passedticks)/(Ticksper.Second));
		break;
		}
		case TENTHSOFSECONDS:
		{
			return -1;
		break;
		}
		case HUNDREDSOFSECONDS:
		{
			return -1;
		break;
		}
		case MICROSECONDS:
		{
			return(int) ((passedticks)/(Ticksper.MicroSecond));
		break;
		}
		default:
		{
			return -1;
		break;
		};
	}
}

int timer::Tic( unsigned char n)
{
	if (n<MAXNUMBEROFTICKS)
		return updatetick( &TicTick[n]);
	else
		return -1;


}
#endif
