Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:18

0001 // @(#)root/mathcore:$Id$
0002 // Author: L. Moneta Fri Aug 15 2008
0003 
0004 /**********************************************************************
0005  *                                                                    *
0006  * Copyright (c) 2008  LCG ROOT Math Team, CERN/PH-SFT                *
0007  *                                                                    *
0008  *                                                                    *
0009  **********************************************************************/
0010 
0011 #ifndef ROOT_Math_IOptions
0012 #define ROOT_Math_IOptions
0013 
0014 #include <iostream>
0015 #include <string>
0016 
0017 namespace ROOT {
0018 
0019 
0020    namespace Math {
0021 
0022 //_______________________________________________________________________________
0023 /**
0024     Generic interface for defining configuration options of a numerical algorithm
0025 
0026     @ingroup NumAlgo
0027 */
0028 class IOptions {
0029 
0030 public:
0031 
0032    IOptions() /* : fExtraOptions(0) */  {}
0033 
0034    virtual ~IOptions() {}// { if (fExtraOptions) delete fExtraOptions; }
0035 
0036    // copy the options
0037    virtual IOptions * Clone() const = 0;
0038 
0039    /** generic  methods for  retrieving options */
0040 
0041    /// set option value
0042    void SetValue(const char * name, double val) { SetRealValue(name,val);}
0043    void SetValue(const char * name, int val) { SetIntValue(name,val);}
0044    void SetValue(const char * name, const char * val) { SetNamedValue(name,val);}
0045 
0046 
0047    double  RValue(const char * name) const;
0048    int   IValue(const char * name) const;
0049    std::string  NamedValue(const char * name) const;
0050 
0051 
0052    // generic method to retrieve  a type
0053    template <typename T>
0054    bool GetValue(const char * name, T & t) const {
0055       bool ret = DoGetValue(name, t);
0056       //if (!ret )  MATH_ERROR_MSG("IOptions::GetValue","option is not existing - returns 0");
0057       return ret;
0058    }
0059 
0060 
0061    // methods to be re-implemented in the derived classes
0062 
0063    virtual bool GetRealValue(const char *, double &) const { return false; }
0064    virtual bool GetIntValue(const char *, int &) const { return false; }
0065    virtual bool GetNamedValue(const char *, std::string &) const { return false; }
0066 
0067    virtual void SetRealValue(const char * , double );
0068    virtual void SetIntValue(const char * , int );
0069    virtual void SetNamedValue(const char * , const char * );
0070 
0071    virtual void Print(std::ostream & = std::cout ) const;
0072 
0073 private:
0074 
0075    bool DoGetValue(const char *name, double &val) const { return GetRealValue(name,val); }
0076 
0077    bool DoGetValue(const char *name, int &val) const { return GetIntValue(name,val); }
0078 
0079    bool DoGetValue(const char *name, std::string &val) const { return GetNamedValue(name,val); }
0080 
0081 
0082 };
0083 
0084 
0085    } // end namespace Math
0086 
0087 } // end namespace ROOT
0088 
0089 #endif