#include "Kernel/stdafx.h"
#include <process.h>
#include <windows.h>
#include <string>

using namespace std;

#pragma hdrstop
#include "Kernel/kernelincludes.h"
#include "Tautology.h"

/**
*  Tautology Detector 1.0
*  author:    Bc. Jan Schindler
*  project:   DP, CVUT, FEL, 2009
*/


float GetMyCPUTime(){
    HANDLE hProcess;    // specifies the process of interest
    FILETIME lpCreationTime;    // when the process was created
    FILETIME lpExitTime;    // when the process exited
    FILETIME lpKernelTime;    // time the process has spent in kernel mode
    FILETIME lpUserTime;
    LARGE_INTEGER t1, t2;


    hProcess = GetCurrentProcess();
    GetProcessTimes(hProcess, &lpCreationTime, &lpExitTime, &lpKernelTime, &lpUserTime);
    memcpy(&t1, &lpUserTime, sizeof(FILETIME));
    memcpy(&t2, &lpKernelTime, sizeof(FILETIME));
    return ((float)(t1.QuadPart+t2.QuadPart)/10000000);
}


int main(){	
	PLA* pla = new PLA();
	cout << "file name:";
    string soubor;
    cin >> soubor;
    pla->LoadPLA(soubor.c_str());
	
	float t1 = GetMyCPUTime(); // start
	
	   // we create the detector
	   TautologyDetector *detector = new TautologyDetector();
	
	   // we want to analyze PLA
       cout << "T: " << detector->isPLAtautology(pla) << endl;
       // eventualy we could analyze SoPLA
	   //cout << "T: " << detector->isSoPLAtautology(sopla) << endl;
	
	   //delete detector;
	
	float t2 = GetMyCPUTime(); // stop - the tautology question is answered
	cout << "time needed for detection: " << t2 - t1 << endl << endl; 
	
	system("PAUSE");
    return EXIT_SUCCESS;
}
