Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
IOptions.h
Go to the documentation of this file.
1// @(#)root/mathcore:$Id$
2// Author: L. Moneta Fri Aug 15 2008
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2008 LCG ROOT Math Team, CERN/PH-SFT *
7 * *
8 * *
9 **********************************************************************/
10
11#ifndef ROOT_Math_IOptions
12#define ROOT_Math_IOptions
13
14#include <iostream>
15#include <string>
16
17namespace ROOT {
18
19
20 namespace Math {
21
22//_______________________________________________________________________________
23/**
24 Generic interface for defining configuration options of a numerical algorithm
25
26 @ingroup NumAlgo
27*/
28class IOptions {
29
30public:
31
32 IOptions() /* : fExtraOptions(0) */ {}
33
34 virtual ~IOptions() {}// { if (fExtraOptions) delete fExtraOptions; }
35
36 // copy the options
37 virtual IOptions * Clone() const = 0;
38
39 /** generic methods for retrieving options */
40
41 /// set option value
42 void SetValue(const char * name, double val) { SetRealValue(name,val);}
43 void SetValue(const char * name, int val) { SetIntValue(name,val);}
44 void SetValue(const char * name, const char * val) { SetNamedValue(name,val);}
45
46
47 double RValue(const char * name) const;
48 int IValue(const char * name) const;
49 std::string NamedValue(const char * name) const;
50
51
52 // generic method to retrieve a type
53 template <typename T>
54 bool GetValue(const char * name, T & t) const {
55 bool ret = DoGetValue(name, t);
56 //if (!ret ) MATH_ERROR_MSG("IOptions::GetValue","option is not existing - returns 0");
57 return ret;
58 }
59
60
61 // methods to be re-implemented in the derived classes
62
63 virtual bool GetRealValue(const char *, double &) const { return false; }
64 virtual bool GetIntValue(const char *, int &) const { return false; }
65 virtual bool GetNamedValue(const char *, std::string &) const { return false; }
66
67 virtual void SetRealValue(const char * , double );
68 virtual void SetIntValue(const char * , int );
69 virtual void SetNamedValue(const char * , const char * );
70
71 virtual void Print(std::ostream & = std::cout ) const;
72
73private:
74
75 bool DoGetValue(const char *name, double &val) const { return GetRealValue(name,val); }
76
77 bool DoGetValue(const char *name, int &val) const { return GetIntValue(name,val); }
78
79 bool DoGetValue(const char *name, std::string &val) const { return GetNamedValue(name,val); }
80
81
82};
83
84
85 } // end namespace Math
86
87} // end namespace ROOT
88
89#endif
char name[80]
Definition TGX11.cxx:110
Generic interface for defining configuration options of a numerical algorithm.
Definition IOptions.h:28
virtual bool GetIntValue(const char *, int &) const
Definition IOptions.h:64
virtual void SetIntValue(const char *, int)
Definition IOptions.cxx:45
void SetValue(const char *name, int val)
Definition IOptions.h:43
virtual ~IOptions()
Definition IOptions.h:34
double RValue(const char *name) const
Definition IOptions.cxx:12
std::string NamedValue(const char *name) const
Definition IOptions.cxx:30
virtual void SetRealValue(const char *, double)
method which need to be re-implemented by the derived classes
Definition IOptions.cxx:40
void SetValue(const char *name, double val)
generic methods for retrieving options
Definition IOptions.h:42
bool DoGetValue(const char *name, std::string &val) const
Definition IOptions.h:79
int IValue(const char *name) const
Definition IOptions.cxx:21
virtual IOptions * Clone() const =0
bool GetValue(const char *name, T &t) const
Definition IOptions.h:54
virtual bool GetRealValue(const char *, double &) const
Definition IOptions.h:63
void SetValue(const char *name, const char *val)
Definition IOptions.h:44
bool DoGetValue(const char *name, double &val) const
Definition IOptions.h:75
virtual void SetNamedValue(const char *, const char *)
Definition IOptions.cxx:50
virtual bool GetNamedValue(const char *, std::string &) const
Definition IOptions.h:65
virtual void Print(std::ostream &=std::cout) const
print options
Definition IOptions.cxx:56
bool DoGetValue(const char *name, int &val) const
Definition IOptions.h:77
Namespace for new Math classes and functions.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.