00001 #ifndef eoFuncPtrStat_h
00002 #define eoFuncPtrStat_h
00003
00004 #include <eoFunctorStore.h>
00005 #include <utils/eoStat.h>
00006
00007 template <class EOT, class T>
00008 class eoFuncPtrStat : public eoStat<EOT, T>
00009 {
00010 public :
00011 typedef T (*func_t)(const eoPop<EOT>&);
00012
00013
00014 eoFuncPtrStat(func_t f, std::string _description = "func_ptr")
00015 : eoStat<EOT, T>(T(), _description), func(f)
00016 {}
00017
00018 using eoStat<EOT, T>::value;
00019
00020 void operator()(const eoPop<EOT>& pop) {
00021 value() = func(pop);
00022 }
00023
00024 private:
00025 func_t func;
00026 };
00027
00028 template <class EOT, class T>
00029 eoFuncPtrStat<EOT, T>& makeFuncPtrStat( T (*func)(const eoPop<EOT>&), eoFunctorStore& store, std::string description = "func") {
00030 return store.storeFunctor(
00031 new eoFuncPtrStat<EOT, T>( func, description)
00032 );
00033 }
00034
00035 #endif
00036