LOOS  v2.3.2
ConvergenceOptions.hpp
1 #if !defined(LOOS_CONVERGENCE_OPTIONS_HPP)
2 #define LOOS_CONVERGENCE_OPTIONS_HPP
3 
4 
5 
6 #include <boost/format.hpp>
7 
8 
9 #include <loos.hpp>
10 
11 
12 namespace loos {
13  namespace OptionsFramework {
14 
16  public:
17  BasicConvergence() : seed(0) { }
18 
19  void addGeneric(po::options_description& o) {
20  o.add_options()
21  ("seed", po::value<uint>(&seed)->default_value(seed), "Random number seed (0 = auto)");
22  };
23 
24  bool postConditions(po::variables_map& vm) {
25  if (seed == 0)
26  seed = randomSeedRNG();
27  else
28  rng_singleton().seed(seed);
29 
30  return(true);
31  }
32 
33  std::string print() const {
34  std::ostringstream oss;
35  oss << boost::format("seed=%d") % seed;
36  return(oss.str());
37  }
38 
39  uint seed;
40  };
41 
42  };
43 
44 };
45 
46 
47 
48 #endif
void addGeneric(po::options_description &o)
Appends generic options (those that the user can see)
bool postConditions(po::variables_map &vm)
Post-processing of options returning true if there were no problems, otherwise false.
uint randomSeedRNG(void)
Randomly seeds the RNG.
base_generator_type & rng_singleton(void)
Suite-wide random number generator singleton.
Namespace for most things not already encapsulated within a class.
std::string print() const
Returns a string listing the encapsulated options, suitable for logging.