00001 00012 #ifndef POPOBJECTVALUEGENERATOR_H_ 00013 #define POPOBJECTVALUEGENERATOR_H_ 00014 00015 #include "RandomEngine.h" 00016 #include "SimObjectPopulation.h" 00017 00019 00025 class PopObjectValueGenerator 00026 { 00027 public: 00028 PopObjectValueGenerator(); 00029 00030 virtual ~PopObjectValueGenerator(); 00031 00033 00037 virtual void prepare(SimObjectPopulation const& pop, size_t idx, RandomEngine *rnd=NULL) = 0; 00038 00040 00044 virtual double generate(RandomEngine *rnd) = 0; 00045 00046 virtual PopObjectValueGenerator* clone(void) const = 0; 00047 }; 00048 00050 00056 /* 00057 class PyPopObjectValueGenerator 00058 { 00059 public: 00060 // PyPopObjectValueGenerator(); 00061 // virtual ~PyPopObjectValueGenerator(); 00062 virtual void prepare(SimObjectPopulation const& pop, RandomEngine *rnd=NULL) 00063 { 00064 //NOOP 00065 }; 00066 00067 virtual double generate(size_t idx, RandomEngine *rnd) 00068 { 00069 return 0.0; 00070 }; 00071 00072 virtual PopObjectValueGenerator* clone(void) const 00073 { 00074 return NULL; 00075 }; 00076 }; 00077 00078 */ 00079 00081 template< typename P> 00082 class PopObjectValueGeneratorSpecialization : public PopObjectValueGenerator 00083 { 00084 00085 public: 00086 00087 virtual void prepare(SimObjectPopulation const& pop, size_t idx, RandomEngine *rnd=NULL) 00088 { 00089 m_pop = dynamic_cast< const P*>( &pop ); 00090 if (m_pop == NULL) { 00091 throw( PCSIM::ConstructionException("PopObjectValueGeneratorSpecialization", "Given Population is NULL.")); 00092 } 00093 m_idx=idx; 00094 } 00095 00096 protected: 00097 size_t m_idx; 00098 const P* m_pop; 00099 }; 00100 00102 class PlainPopObjectValueGenerator : public PopObjectValueGeneratorSpecialization<SimObjectPopulation> 00103 { 00104 }; 00105 00106 #include "SpatialSimObjectPopulation.h" 00107 00109 class SpatialPopObjectValueGenerator : public PopObjectValueGeneratorSpecialization<SpatialSimObjectPopulation> 00110 { 00111 }; 00112 00113 #include "SpatialFamilyPopulation.h" 00114 00116 class FamilyPopObjectFactory : public PopObjectValueGeneratorSpecialization<SpatialFamilyPopulation> 00117 { 00118 }; 00119 00120 #include "AugmentedSpatialPopulation.h" 00121 00123 class AttributePopObjectValueGenerator : public PopObjectValueGeneratorSpecialization<AugmentedSpatialPopulation> 00124 { 00125 }; 00126 00127 #endif //POPOBJECTVALUEGENERATOR_H_