Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

FitterOptionParser.cpp

Go to the documentation of this file.
00001  /**********************************************************************
00002   *                                                                    *
00003   * Copyright (c) 2002 Lorenzo Moneta, CERN/IT                       *
00004   *                   <Lorenzo.Moneta.cern.ch>                       *
00005   *                                                                    *
00006   * This library is free software; you can redistribute it and/or      *
00007   * modify it under the terms of the GNU Lesser General Public         *
00008   * License as published by the Free Software Foundation; either       *
00009   * version 2.1 of the License, or (at your option) any later version. *
00010   *                                                                    *
00011   * This library is distributed in the hope that it will be useful,    *
00012   * but WITHOUT ANY WARRANTY; without even the implied warranty of     *
00013   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   *
00014   * Lesser General Public License for more details.                    *
00015   *                                                                    *
00016   * You should have received a copy of the GNU Lesser General Public   *
00017   * License along with this library (see file COPYING); if not, write  *
00018   * to the Free Software Foundation, Inc., 59 Temple Place, Suite      *
00019   * 330, Boston, MA 02111-1307 USA, or contact the author.             *
00020   *                                                                    *
00021   **********************************************************************/
00022 
00023 // Implementation file for class FitterOptionParser
00024 // 
00025 // Authors  : Lorenzo Moneta , Jakub Moscicki
00026 // Created  : Fri Oct 11 12:10:34 2002
00027 // 
00028 // Last update: Fri Oct 11 12:10:34 2002
00029 // 
00030 
00031 #include "FitterOptionParser.h"
00032 
00033 
00034 #ifdef OLDSTREAMS
00035 # include <strstream>
00036 # define istringstream istrstream
00037 #else
00038 # include <sstream>
00039 #endif
00040 
00041 
00042 namespace Anaphe  { 
00043   namespace AIDA_Fitter_FML { 
00044 
00045 
00046 FitterOptionParser::FitterOptionParser(const std::string & opt) 
00047 {
00048   // defaults 
00049   m_error_up = 1.0; 
00050   m_print_level = -1; 
00051   m_use_minos = false; 
00052 
00053   m_options = opt; 
00054   // unpack options 
00055   getValueOption("printLevel",m_print_level); 
00056   getValueOption("errorUP",m_error_up); 
00057   m_use_minos = getBoolOption("useMinos"); 
00058   
00059 }
00060 
00061 FitterOptionParser::~FitterOptionParser() 
00062 {
00063 }
00064 
00065 FitterOptionParser::FitterOptionParser(const FitterOptionParser &) 
00066 {
00067 }
00068 
00069 FitterOptionParser & FitterOptionParser::operator = (const FitterOptionParser &rhs) 
00070 {
00071    if (this == &rhs) return *this;  // time saving self-test
00072 
00073    return *this;
00074 }
00075 
00076 int  FitterOptionParser::printLevel() const { return m_print_level; } 
00077 
00078 bool  FitterOptionParser::useMinos() const { return m_use_minos; } 
00079 
00080 double  FitterOptionParser::errorUP() const { return m_error_up; } 
00081 
00082 
00083 template <class T> 
00084 void  FitterOptionParser::getValueOption(const std::string & keyword, T & value) 
00085 { 
00086   std::string::size_type idx;
00087   idx = m_options.find( keyword );
00088   if ( idx != std::string::npos ) {
00089     std::string substring1 = m_options.substr( idx + keyword.length() );
00090     std::string::size_type idx1 = substring1.find( "=" );
00091     if ( idx1 != std::string::npos ) {
00092       std::istringstream is( substring1.substr( idx1 + 1 ).c_str() );
00093       is >> std::ws;
00094       if ( ! is.eof() ) {
00095         is >> value;
00096       }
00097     }
00098   }
00099 }
00100 
00101 bool  FitterOptionParser::getBoolOption(const std::string & keyword) 
00102 { 
00103   bool value = false; 
00104   if ( m_options.find( keyword ) != std::string::npos ) value = true;
00105   return value; 
00106 }
00107 
00108   }     // end of namespace Anaphe::AIDA_Fitter_FML
00109 } 

Generated on Tue May 20 14:49:01 2003 for AIDA_Fitter_FML by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002