BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
ROOT::Math::GenAlgoOptions Class Reference

Description

class implementing generic options for a numerical algorithm Just store the options in a map of string-value pairs

Definition at line 31 of file GenAlgoOptions.h.

Inheritance diagram for ROOT::Math::GenAlgoOptions:
[legend]
Collaboration diagram for ROOT::Math::GenAlgoOptions:
[legend]

Public Member Functions

 GenAlgoOptions ()
 
virtual ~GenAlgoOptions ()
 
virtual IOptionsClone () const
 
virtual bool GetIntValue (const char *name, int &val) const
 
virtual bool GetNamedValue (const char *name, std::string &val) const
 
virtual bool GetRealValue (const char *name, double &val) const
 
template<typename T >
bool GetValue (const char *name, T &t) const
 
int IValue (const char *name) const
 
std::string NamedValue (const char *name) const
 
virtual void Print (std::ostream &os=std::cout) const
 print options More...
 
double RValue (const char *name) const
 
virtual void SetIntValue (const char *name, int val)
 
virtual void SetNamedValue (const char *name, const char *val)
 
virtual void SetRealValue (const char *name, double val)
 method wich need to be re-implemented by the derived classes More...
 
void SetValue (const char *name, const char *val)
 
void SetValue (const char *name, double val)
 set option value More...
 
void SetValue (const char *name, int val)
 

Static Public Member Functions

static IOptionsDefault (const char *algoname)
 
static IOptionsFindDefault (const char *algoname)
 
static void PrintAllDefault (std::ostream &os=std::cout)
 print all the default options More...
 

Private Member Functions

bool DoGetValue (const char *name, double &val) const
 
bool DoGetValue (const char *name, int &val) const
 
bool DoGetValue (const char *name, std::string &val) const
 

Static Private Member Functions

template<class M >
static const M::mapped_type * FindValue (const std::string &name, const M &opts)
 
template<class M >
static void InsertValue (const std::string &name, M &opts, const typename M::mapped_type &value)
 
template<class M >
static void Print (const M &opts, std::ostream &os)
 

Private Attributes

std::map< std::string, int > fIntOpts
 
std::map< std::string, std::string > fNamOpts
 
std::map< std::string, double > fRealOpts
 

Constructor & Destructor Documentation

◆ GenAlgoOptions()

ROOT::Math::GenAlgoOptions::GenAlgoOptions ( )
inline

Definition at line 35 of file GenAlgoOptions.h.

35 {}

Referenced by Clone().

◆ ~GenAlgoOptions()

virtual ROOT::Math::GenAlgoOptions::~GenAlgoOptions ( )
inlinevirtual

Definition at line 37 of file GenAlgoOptions.h.

37 {}// { if (fExtraOptions) delete fExtraOptions; }

Member Function Documentation

◆ Clone()

virtual IOptions* ROOT::Math::GenAlgoOptions::Clone ( ) const
inlinevirtual

generic methods for retrivieng options

Implements ROOT::Math::IOptions.

Definition at line 46 of file GenAlgoOptions.h.

46  {
47  return new GenAlgoOptions(*this);
48  }

References GenAlgoOptions().

Here is the call graph for this function:

◆ Default()

static IOptions& ROOT::Math::GenAlgoOptions::Default ( const char *  algoname)
static

◆ DoGetValue() [1/3]

bool ROOT::Math::IOptions::DoGetValue ( const char *  name,
double &  val 
) const
inlineprivateinherited

Definition at line 103 of file IOptions.h.

103 { return GetRealValue(name,val); }
virtual bool GetRealValue(const char *, double &) const
Definition: IOptions.h:83

References ROOT::Math::IOptions::GetRealValue().

Referenced by ROOT::Math::IOptions::GetValue().

Here is the call graph for this function:

◆ DoGetValue() [2/3]

bool ROOT::Math::IOptions::DoGetValue ( const char *  name,
int &  val 
) const
inlineprivateinherited

Definition at line 105 of file IOptions.h.

105 { return GetIntValue(name,val); }
virtual bool GetIntValue(const char *, int &) const
Definition: IOptions.h:85

References ROOT::Math::IOptions::GetIntValue().

Here is the call graph for this function:

◆ DoGetValue() [3/3]

bool ROOT::Math::IOptions::DoGetValue ( const char *  name,
std::string &  val 
) const
inlineprivateinherited

Definition at line 107 of file IOptions.h.

107 { return GetNamedValue(name,val); }
virtual bool GetNamedValue(const char *, std::string &) const
Definition: IOptions.h:87

References ROOT::Math::IOptions::GetNamedValue().

Here is the call graph for this function:

◆ FindDefault()

static IOptions* ROOT::Math::GenAlgoOptions::FindDefault ( const char *  algoname)
static

◆ FindValue()

template<class M >
static const M::mapped_type* ROOT::Math::GenAlgoOptions::FindValue ( const std::string &  name,
const M &  opts 
)
inlinestaticprivate

Definition at line 117 of file GenAlgoOptions.h.

117  {
118  typename M::const_iterator pos;
119  pos = opts.find(name);
120  if (pos == opts.end()) {
121  return 0;
122  }
123  return &((*pos).second);
124  }

Referenced by GetIntValue(), GetNamedValue(), and GetRealValue().

◆ GetIntValue()

virtual bool ROOT::Math::GenAlgoOptions::GetIntValue ( const char *  name,
int &  val 
) const
inlinevirtual

Reimplemented from ROOT::Math::IOptions.

Definition at line 60 of file GenAlgoOptions.h.

60  {
61  const int * pval = FindValue(name, fIntOpts);
62  if (!pval) return false;
63  val = *pval;
64  return true;
65  }
static const M::mapped_type * FindValue(const std::string &name, const M &opts)
std::map< std::string, int > fIntOpts

References FindValue(), and fIntOpts.

Here is the call graph for this function:

◆ GetNamedValue()

virtual bool ROOT::Math::GenAlgoOptions::GetNamedValue ( const char *  name,
std::string &  val 
) const
inlinevirtual

Reimplemented from ROOT::Math::IOptions.

Definition at line 67 of file GenAlgoOptions.h.

67  {
68  const std::string * pval = FindValue(name, fNamOpts);
69  if (!pval) return false;
70  val = *pval;
71  return true;
72  }
std::map< std::string, std::string > fNamOpts

References FindValue(), and fNamOpts.

Here is the call graph for this function:

◆ GetRealValue()

virtual bool ROOT::Math::GenAlgoOptions::GetRealValue ( const char *  name,
double &  val 
) const
inlinevirtual

Reimplemented from ROOT::Math::IOptions.

Definition at line 53 of file GenAlgoOptions.h.

53  {
54  const double * pval = FindValue(name, fRealOpts);
55  if (!pval) return false;
56  val = *pval;
57  return true;
58  }
std::map< std::string, double > fRealOpts

References FindValue(), and fRealOpts.

Here is the call graph for this function:

◆ GetValue()

template<typename T >
bool ROOT::Math::IOptions::GetValue ( const char *  name,
T &  t 
) const
inlineinherited

Definition at line 73 of file IOptions.h.

73  {
74  bool ret = DoGetValue(name, t);
75  //if (!ret ) MATH_ERROR_MSG("IOptions::GetValue","option is not existing - returns 0");
76  return ret;
77  }
bool DoGetValue(const char *name, double &val) const
Definition: IOptions.h:103

References ROOT::Math::IOptions::DoGetValue().

Here is the call graph for this function:

◆ InsertValue()

template<class M >
static void ROOT::Math::GenAlgoOptions::InsertValue ( const std::string &  name,
M &  opts,
const typename M::mapped_type &  value 
)
inlinestaticprivate

Definition at line 127 of file GenAlgoOptions.h.

127  {
128  typename M::iterator pos;
129  pos = opts.find(name);
130  if (pos != opts.end()) {
131  pos->second = value;
132  }
133  else {
134  opts.insert(typename M::value_type(name, value) );
135  }
136  }

Referenced by SetIntValue(), SetNamedValue(), and SetRealValue().

◆ IValue()

int ROOT::Math::IOptions::IValue ( const char *  name) const
inlineinherited

Definition at line 56 of file IOptions.h.

56  {
57  int val = 0;
58  bool ret = GetIntValue(name,val);
59  if (!ret ) MATH_ERROR_MSGVAL("IOptions::IValue"," return 0 - integer option not found",name);
60  return val;
61  }
#define MATH_ERROR_MSGVAL(loc, str, x)
Definition: Error.h:69

References ROOT::Math::IOptions::GetIntValue(), and MATH_ERROR_MSGVAL.

Here is the call graph for this function:

◆ NamedValue()

std::string ROOT::Math::IOptions::NamedValue ( const char *  name) const
inlineinherited

Definition at line 63 of file IOptions.h.

63  {
64  std::string val;
65  bool ret = GetNamedValue(name,val);
66  if (!ret ) MATH_ERROR_MSGVAL("IOptions::NamedValue"," return empty string - named option not found",name);
67  return val;
68  }

References ROOT::Math::IOptions::GetNamedValue(), and MATH_ERROR_MSGVAL.

Here is the call graph for this function:

◆ Print() [1/2]

template<class M >
static void ROOT::Math::GenAlgoOptions::Print ( const M &  opts,
std::ostream &  os 
)
inlinestaticprivate

Definition at line 139 of file GenAlgoOptions.h.

139  {
140  //const std::ios_base::fmtflags prevFmt = os.flags();
141  for (typename M::const_iterator pos = opts.begin(); pos != opts.end(); ++pos)
142  os << std::setw(25) << pos->first << " : " << std::setw(15) << pos->second << std::endl;
143  }

◆ Print() [2/2]

virtual void ROOT::Math::GenAlgoOptions::Print ( std::ostream &  os = std::cout) const
inlinevirtual

print options

Reimplemented from ROOT::Math::IOptions.

Definition at line 89 of file GenAlgoOptions.h.

89  {
90  Print(fNamOpts,os);
91  Print(fIntOpts,os);
92  Print(fRealOpts,os);
93  }
virtual void Print(std::ostream &os=std::cout) const
print options

References fIntOpts, fNamOpts, and fRealOpts.

◆ PrintAllDefault()

static void ROOT::Math::GenAlgoOptions::PrintAllDefault ( std::ostream &  os = std::cout)
static

print all the default options

◆ RValue()

double ROOT::Math::IOptions::RValue ( const char *  name) const
inlineinherited

Definition at line 49 of file IOptions.h.

49  {
50  double val = 0;
51  bool ret = GetRealValue(name,val);
52  if (!ret ) MATH_ERROR_MSGVAL("IOptions::RValue"," return 0 - real option not found",name);
53  return val;
54  }

References ROOT::Math::IOptions::GetRealValue(), and MATH_ERROR_MSGVAL.

Here is the call graph for this function:

◆ SetIntValue()

virtual void ROOT::Math::GenAlgoOptions::SetIntValue ( const char *  name,
int  val 
)
inlinevirtual

Reimplemented from ROOT::Math::IOptions.

Definition at line 79 of file GenAlgoOptions.h.

79  {
80  InsertValue(name, fIntOpts, val);
81  }
static void InsertValue(const std::string &name, M &opts, const typename M::mapped_type &value)

References fIntOpts, and InsertValue().

Here is the call graph for this function:

◆ SetNamedValue()

virtual void ROOT::Math::GenAlgoOptions::SetNamedValue ( const char *  name,
const char *  val 
)
inlinevirtual

Reimplemented from ROOT::Math::IOptions.

Definition at line 83 of file GenAlgoOptions.h.

83  {
84  InsertValue(name, fNamOpts, std::string(val));
85  }

References fNamOpts, and InsertValue().

Here is the call graph for this function:

◆ SetRealValue()

virtual void ROOT::Math::GenAlgoOptions::SetRealValue ( const char *  name,
double  val 
)
inlinevirtual

method wich need to be re-implemented by the derived classes

Reimplemented from ROOT::Math::IOptions.

Definition at line 75 of file GenAlgoOptions.h.

75  {
76  InsertValue(name, fRealOpts, val);
77  }

References fRealOpts, and InsertValue().

Here is the call graph for this function:

◆ SetValue() [1/3]

void ROOT::Math::IOptions::SetValue ( const char *  name,
const char *  val 
)
inlineinherited

Definition at line 46 of file IOptions.h.

46 { SetNamedValue(name,val);}
virtual void SetNamedValue(const char *, const char *)
Definition: IOptions.h:94

References ROOT::Math::IOptions::SetNamedValue().

Here is the call graph for this function:

◆ SetValue() [2/3]

void ROOT::Math::IOptions::SetValue ( const char *  name,
double  val 
)
inlineinherited

set option value

generic methods for retrivieng options

Definition at line 44 of file IOptions.h.

44 { SetRealValue(name,val);}
virtual void SetRealValue(const char *, double)
method wich need to be re-implemented by the derived classes
Definition: IOptions.h:90

References ROOT::Math::IOptions::SetRealValue().

Here is the call graph for this function:

◆ SetValue() [3/3]

void ROOT::Math::IOptions::SetValue ( const char *  name,
int  val 
)
inlineinherited

Definition at line 45 of file IOptions.h.

45 { SetIntValue(name,val);}
virtual void SetIntValue(const char *, int)
Definition: IOptions.h:92

References ROOT::Math::IOptions::SetIntValue().

Here is the call graph for this function:

Member Data Documentation

◆ fIntOpts

std::map<std::string, int> ROOT::Math::GenAlgoOptions::fIntOpts
private

Definition at line 147 of file GenAlgoOptions.h.

Referenced by GetIntValue(), Print(), and SetIntValue().

◆ fNamOpts

std::map<std::string, std::string> ROOT::Math::GenAlgoOptions::fNamOpts
private

Definition at line 148 of file GenAlgoOptions.h.

Referenced by GetNamedValue(), Print(), and SetNamedValue().

◆ fRealOpts

std::map<std::string, double> ROOT::Math::GenAlgoOptions::fRealOpts
private

Definition at line 146 of file GenAlgoOptions.h.

Referenced by GetRealValue(), Print(), and SetRealValue().


The documentation for this class was generated from the following file: