/***************************************************************************
 *   Copyright (C) 2000-2010 by Noel Novelli                               *
 *   novelli@lif.univ-mrs.fr                                               *
 *                                                                         *
 *   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.             *
 ***************************************************************************/


#include <iostream>
#include "algoCFUN.h"
#include "partitionCFUN.h"
#include "relation.h"
#include "parseCmdLine.h"


int main( int argc, char* argv[] )
{
    CFunCmdLine cfunCmdLine( argc, argv );

    int rc = cfunCmdLine.error( );
    if (  rc != 0 ) {
        cfunCmdLine.usage( argv[0] );
        cout << "argc = " << argc << endl;
        for ( int i = 0; i < argc; ++i ) {
            cout << "\t" << ( i == rc ? "**" : "" ) << "argv[" << i << "]= " << argv[i] << endl;
        }
        if ( rc == -1 ) {
            cout << "**Number of parameter insufficient" << endl;
        }
        if ( rc == -3 ) {
            cout << "**Incorrect values of parameters" << endl;
        }
        return -1;
    }
    try {
		PartitionCFUN::m_uMinSup = cfunCmdLine._minSup;
        LevelCFUN::m_uMinSupCFD  = cfunCmdLine._minSupCFD;

        Relation relation ( argv[1] );

        cout << "CFun on " << argv[1]
                << "\n\t#Tuples    : " << relation.getNbTuples()
                << "\n\t#Attributes: " << relation.getNbCol()
                << "\n\tminSup     : " << cfunCmdLine._minSup
                << "\n\tminCFD     : " << cfunCmdLine._minSupCFD
                << "\n\tPruning    : " << (cfunCmdLine._bPrune ? "ON" : "OFF")
                << endl << endl;


	        // CFun algo in RAM....
        cfun ( relation, 2, cfunCmdLine._bPrune, cfunCmdLine._bWaitUser,
               cfunCmdLine._bStdOutput );

    } catch ( exception& e ) {
        std::cerr << e.what() << std::endl;
    }

    return 0;
}

