RandomEngineRegistry.h
Go to the documentation of this file.
1 #ifndef _fwk_RandomEngineRegistry_h_
2 #define _fwk_RandomEngineRegistry_h_
3 
12 #include <utl/Singleton.h>
13 #include <utl/AugerException.h>
14 #include <utl/RandomEngine.h>
15 #include <utl/ShadowPtr.h>
16 #include <string>
17 #include <map>
18 
19 
20 namespace fwk {
21 
37  class RandomEngineRegistry : public utl::Singleton<RandomEngineRegistry> {
38 
39  public:
43  eDetector = 0,
46  };
47 
56 
57  public:
59  InvalidRandomEngineException(const std::string& message = "")
60  : AugerException(message) { }
61 
63  virtual std::string GetExceptionName() const
64  { return "Invalid random engine in registry exception"; }
65 
66  };
67 
70 
71  private:
74 
76  void Init();
77 
79  void RegisterOne(const RandomEngineID id, utl::RandomEngine* const engine);
80 
81  void GenerateSeeds(long* const seed, const int n) const;
82 
83  typedef std::map<RandomEngineID, utl::RandomEngine*> Registry;
85 
87 
88  };
89 
90 }
91 
92 
93 #endif
Base class for all exceptions used in the auger offline code.
utl::ShadowPtr< Registry > fRegistry
utl::RandomEngine & Get(const RandomEngineID id=eDetector)
Get a pre-defined random engine.
Wraps the random number engine used to generate distributions.
Definition: RandomEngine.h:27
void Init()
Initialise the registry.
virtual std::string GetExceptionName() const
Retrieve verbose exception name.
void GenerateSeeds(long *const seed, const int n) const
Collection of pre-defined random engines.
InvalidRandomEngineException(const std::string &message="")
Construct random engine exception with message.
void RegisterOne(const RandomEngineID id, utl::RandomEngine *const engine)
Register an engine.
std::map< RandomEngineID, utl::RandomEngine * > Registry
RandomEngineID
Identifiers for all pre-defined random engines.
Base class for exceptions in the RandomEngineRegistry.
Curiously Recurring Template Pattern (CRTP) for Meyers singleton.
Definition: Singleton.h:36

, generated on Tue Sep 26 2023.