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

#include "pla.h"

int main(int argc, char *argv[])
{
    Pla *pla;
    clock_t t1, t2;

    try {
        switch(argc){
            case 2:
                pla = new Pla(argv[1]);
                break;
            case 3:
                cout << "pouziti: main [-i pocet_iteraci] [input_file]" << endl;
                cout << "[-i pocet_iteraci] - nastavuje pocet iteraci algoritmu, zadava se v nasobcich poctu promennych" << endl;
                exit(2);
            case 4:
                if (strncmp(argv[1], "-i", 2) == 0)
                    pla = new Pla(argv[3], atoi(argv[2]));
                else {
                    cout << "pouziti: main [-i pocet_iteraci] [input_file]" << endl;
                    cout << "[-i pocet_iteraci] - nastavuje pocet iteraci algoritmu, zadava se v nasobcich poctu promennych" << endl;
                    exit(2);
                }
                break;
            default:
                cout << "pouziti: main [-i pocet_iteraci] [input_file]" << endl;
                cout << "[-i pocet_iteraci] - nastavuje pocet iteraci algoritmu, zadava se v nasobcich poctu promennych" << endl;
                exit(2);
        }
        t1 = clock();
        pla->run();
        t2 = clock();
        cout << "funkce byla minimalizovana za " << difftime(t2, t1)/CLOCKS_PER_SEC << " sekund" << endl;
    }
    catch(std::runtime_error &e){
        cout << e.what() << endl;
    }


    return 0;
}
