[3f9eba] | 1 | /*
|
---|
| 2 | * RandomNumberEngine_Encapsulation.hpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: Jan 01, 2011
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef RANDOMNUMBERENGINE_ENCAPSULATION_HPP_
|
---|
| 9 | #define RANDOMNUMBERENGINE_ENCAPSULATION_HPP_
|
---|
| 10 |
|
---|
| 11 | // include config.h
|
---|
| 12 | #ifdef HAVE_CONFIG_H
|
---|
| 13 | #include <config.h>
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
| 16 | #include <typeinfo>
|
---|
| 17 |
|
---|
| 18 | #include "RandomNumberEngine.hpp"
|
---|
| 19 | #include "RandomNumberGeneratorFactory.hpp"
|
---|
| 20 |
|
---|
| 21 | #include <boost/nondet_random.hpp>
|
---|
| 22 | #include <boost/random.hpp>
|
---|
| 23 | #include <boost/random/additive_combine.hpp>
|
---|
| 24 | #include <boost/random/discard_block.hpp>
|
---|
| 25 | #include <boost/random/inversive_congruential.hpp>
|
---|
| 26 | #include <boost/random/lagged_fibonacci.hpp>
|
---|
| 27 | #include <boost/random/linear_congruential.hpp>
|
---|
| 28 | #include <boost/random/linear_feedback_shift.hpp>
|
---|
| 29 | #include <boost/random/mersenne_twister.hpp>
|
---|
| 30 | #include <boost/random/random_number_generator.hpp>
|
---|
| 31 | #include <boost/random/ranlux.hpp>
|
---|
| 32 | #include <boost/random/shuffle_output.hpp>
|
---|
| 33 | #include <boost/random/subtract_with_carry.hpp>
|
---|
| 34 | #include <boost/random/xor_combine.hpp>
|
---|
| 35 |
|
---|
| 36 | #include "unittests/RandomNumberGeneratorFactoryUnitTest.hpp"
|
---|
| 37 |
|
---|
| 38 | /** Template class that encapsulates the random number engines from
|
---|
| 39 | * random::boost.
|
---|
| 40 | *
|
---|
| 41 | *
|
---|
| 42 | * We need one template parameters:
|
---|
| 43 | * -# the engine - generates uniform random numbers
|
---|
| 44 | */
|
---|
| 45 | template <class engine>
|
---|
| 46 | class RandomNumberEngine_Encapsulation : public RandomNumberEngine
|
---|
| 47 | {
|
---|
| 48 | /**
|
---|
| 49 | * Factory is friend such that it can access private cstor.
|
---|
| 50 | */
|
---|
| 51 | friend class RandomNumberGeneratorFactory;
|
---|
| 52 | friend class RandomNumberGeneratorFactoryTest;
|
---|
| 53 |
|
---|
| 54 | public:
|
---|
| 55 | /** Set the engine's seed.
|
---|
| 56 | *
|
---|
| 57 | * @param _seed seed to set to
|
---|
| 58 | */
|
---|
| 59 | void seed(unsigned int _seed) {
|
---|
| 60 | engine_type.seed(_seed);
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | /** Getter for the type name of the internal engine.
|
---|
| 64 | *
|
---|
| 65 | */
|
---|
| 66 | std::string name() {
|
---|
| 67 | return typeid(engine_type).name();
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | /** Getter for the engine instance.
|
---|
| 71 | *
|
---|
| 72 | * @return reference to instance
|
---|
| 73 | */
|
---|
| 74 | engine& getEngine() {
|
---|
| 75 | return engine_type;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | /** Constructor that instantiates a specific random number generator and
|
---|
| 79 | * distribution.
|
---|
| 80 | * @param _engine_type instance of the desired engine
|
---|
| 81 | */
|
---|
| 82 | RandomNumberEngine_Encapsulation()
|
---|
| 83 | {}
|
---|
| 84 |
|
---|
| 85 | /** Destructor of the class.
|
---|
| 86 | *
|
---|
| 87 | */
|
---|
| 88 | ~RandomNumberEngine_Encapsulation() {}
|
---|
| 89 | private:
|
---|
| 90 | engine engine_type;
|
---|
| 91 | };
|
---|
| 92 |
|
---|
| 93 | #endif /* RANDOMNUMBERENGINE_ENCAPSULATION_HPP_ */
|
---|