00001 /*************************************************************************** 00002 * Copyright (C) 2007 by Universidad Nacional de Colombia * 00003 * http://www.unal.edu.co * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 #include "TarisApplication.h" 00021 00022 TarisApplication::TarisApplication() 00023 { 00024 debugLevel = 0 ; 00025 doubleThresholdComparison = 1e-6 ; 00026 } 00027 00028 TarisApplication::~TarisApplication() 00029 { 00030 } 00031 00032 TarisApplication* TarisApplication::instance = NULL ; 00033 TarisApplication* TarisApplication::Instance() 00034 { 00035 if( instance == NULL ) 00036 instance = new TarisApplication() ; 00037 return instance ; 00038 } 00039 00040 uint TarisApplication::getDebugLevel() const 00041 { 00042 return debugLevel ; 00043 } 00044 00045 void TarisApplication::setDebugLevel( uint debugLevel ) 00046 { 00047 this->debugLevel = debugLevel ; 00048 } 00049 00050 double TarisApplication::getDoubleThresholdComparison() const 00051 { 00052 return doubleThresholdComparison ; 00053 } 00054 00055 void TarisApplication::setDoubleThresholdComparison( double doubleThresholdComparison ) 00056 { 00057 this->doubleThresholdComparison = doubleThresholdComparison ; 00058 } 00059 00069 char* TarisApplication::extractParameter( int argc, char **argv, char *param, char *def ) 00070 { 00071 int numberOfParameters = argc - 1 ; 00072 bool in = false ; 00073 00074 for( int i=0; i < numberOfParameters; i++ ){ 00075 if ( strcmp( argv[i+1], param ) == 0 ){ 00076 if ( argv[i+2] != 0 ){ 00077 in = true ; 00078 return argv[i+2] ; 00079 }else{ 00080 cerr << "Can't find asked option " << param << endl ; 00081 exit(-1) ; 00082 } 00083 } 00084 } 00085 00086 if( strlen( def ) != 0 ){ 00087 if( in == false ) // Retorna el valor por omisión 00088 return def ; 00089 }else{ 00090 cerr << "Parameter " << param << " is required" << endl ; 00091 exit(-1) ; 00092 } 00093 } 00094