00001 #ifndef RANDOMDISTRIBUTIONBASE_H_ 00002 #define RANDOMDISTRIBUTIONBASE_H_ 00003 00011 #include <boost/shared_ptr.hpp> 00012 using boost::shared_ptr; 00013 00014 #include <boost/random.hpp> 00015 00016 #include <vector> 00017 00018 #include "RandomEngine.h" 00019 00021 class RandomDistribution 00022 { 00023 public: 00024 virtual ~RandomDistribution() {}; 00026 00027 double operator()(RandomEngine &eng ) { return get( eng ); }; 00028 shared_ptr< std::vector<double> > operator()(RandomEngine &eng, size_t n ); 00029 virtual RandomDistribution *clone(void) const = 0; 00030 protected: 00031 virtual double get( RandomEngine &eng ) { return 0; }; 00032 }; 00033 00035 template< typename boost_dist > 00036 class RandomDistributionBoostImplementation : public RandomDistribution 00037 { 00038 protected: 00039 typedef boost_dist boost_dist_t; 00040 00041 public: 00042 RandomDistributionBoostImplementation( boost_dist const& d ) : m_dist( d ) {}; 00043 virtual ~RandomDistributionBoostImplementation() {}; 00044 00045 virtual double get( RandomEngine &eng ) 00046 { 00047 return m_dist( eng ); 00048 }; 00049 00050 virtual RandomDistribution *clone(void) const 00051 { 00052 return new RandomDistributionBoostImplementation( m_dist ); 00053 }; 00054 00055 private: 00056 boost_dist m_dist; 00057 00058 }; 00059 #endif