/*LICENSE_START*/
/*
 *  Copyright (C) 2014  Washington University School of Medicine
 *
 *  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.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
/*LICENSE_END*/

#include "AlgorithmName.h"
#include "AlgorithmException.h"

using namespace caret;
using namespace std;

AString AlgorithmName::getCommandSwitch()
{
    return "-command-switch";
}

AString AlgorithmName::getShortDescription()
{
    return "SHORT DESCRIPTION";
}

OperationParameters* AlgorithmName::getParameters()
{
    OperationParameters* ret = new OperationParameters();
    //ret->addSurfaceParameter(1, "surface", "the surface to compute on");
    
    //ret->addMetricOutputParameter(2, "metric-out", "the output metric");
    
    //OptionalParameter* columnSelect = ret->createOptionalParameter(3, "-column", "select a single column");
    //columnSelect->addStringParameter(1, "column", "the column number or name");
    
    ret->setHelpText(
        AString("This is where you set the help text.  ") +
        "DO NOT add the info about what the command line format is, and do not give the command switch, " +
        "short description, or the short descriptions of parameters.  " +
        "Do not indent, manually break long lines, or format the text in any way " +
        "other than to separate paragraphs within the help text prose, usually with two newlines."
    );
    return ret;
}

void AlgorithmName::useParameters(OperationParameters* myParams, ProgressObject* myProgObj)
{
    //SurfaceFile* mySurf = myParams->getSurface(1);//gets the surface with key 1
    //MetricFile* myMetricOut = myParams->getOutputMetric(2);//gets the output metric with key 2
    /*OptionalParameter* columnSelect = myParams->getOptionalParameter(3);//gets optional parameter with key 3
    int columnNum = -1;
    if (columnSelect->m_present)
    {//set up to use the single column
        columnNum = (int)myMetric->getMapIndexFromNameOrNumber(columnSelect->getString(1));
        if (columnNum < 0)
        {
            throw AlgorithmException("invalid column specified");
        }
    }//*/
    AlgorithmName(myProgObj /*INSERT PARAMETERS HERE*/);//executes the algorithm
}

AlgorithmName::AlgorithmName(ProgressObject* myProgObj /*INSERT PARAMETERS HERE*/) : AbstractAlgorithm(myProgObj)
{
    /*ProgressObject* subAlgProgress1 = NULL;//uncomment these if you use another algorithm inside here
    if (myProgObj != NULL)
    {
        subAlgProgress1 = myProgObj->addAlgorithm(AlgorithmInsertNameHere::getAlgorithmWeight());
    }//*/
    LevelProgress myProgress(myProgObj);//this line sets the algorithm up to use the progress object, and will finish the progress object automatically when the algorithm terminates
    //myProgress.reportProgress(0.5f);//this is how you say you are halfway done with the INTERNAL work of the algorithm
    //will report finished automatically when this function ends (myProgress goes out of scope, destructor triggers finish)
}

float AlgorithmName::getAlgorithmInternalWeight()
{
    return 1.0f;//override this if needed, if the progress bar isn't smooth
}

float AlgorithmName::getSubAlgorithmWeight()
{
    //return AlgorithmInsertNameHere::getAlgorithmWeight();//if you use a subalgorithm
    return 0.0f;
}
