diff --git a/eo/src/utils/eoCheckPoint.h b/eo/src/utils/eoCheckPoint.h index 849a5b0ee..d2c1cadc4 100644 --- a/eo/src/utils/eoCheckPoint.h +++ b/eo/src/utils/eoCheckPoint.h @@ -32,6 +32,7 @@ #include #include + /** eoCheckPoint is a container class. It contains std::vectors of (pointers to) eoContinue (modif. MS July 16. 2002) diff --git a/eo/src/utils/eoFileMonitor.cpp b/eo/src/utils/eoFileMonitor.cpp index 1b42bbd84..f5fcd8d65 100644 --- a/eo/src/utils/eoFileMonitor.cpp +++ b/eo/src/utils/eoFileMonitor.cpp @@ -62,8 +62,9 @@ eoMonitor& eoFileMonitor::operator()(void) eoMonitor& eoFileMonitor::operator()(std::ostream& os) { + iterator it = vec.begin(); - + os << (*it)->getValue(); for(++it; it != vec.end(); ++it) diff --git a/eo/src/utils/eoFuncPtrStat.h b/eo/src/utils/eoFuncPtrStat.h new file mode 100644 index 000000000..04675ac73 --- /dev/null +++ b/eo/src/utils/eoFuncPtrStat.h @@ -0,0 +1,36 @@ +#ifndef eoFuncPtrStat_h +#define eoFuncPtrStat_h + +#include +#include + +template +class eoFuncPtrStat : public eoStat +{ +public : + typedef T (*func_t)(const eoPop&); + + + eoFuncPtrStat(func_t f, std::string _description = "func_ptr") + : eoStat(T(), _description), func(f) + {} + + using eoStat::value; + + void operator()(const eoPop& pop) { + value() = func(pop); + } + +private: + func_t func; +}; + +template +eoFuncPtrStat& makeFuncPtrStat( T (*func)(const eoPop&), eoFunctorStore& store, std::string description = "func") { + return store.storeFunctor( + new eoFuncPtrStat( func, description) + ); +} + +#endif + diff --git a/eo/src/utils/eoGnuplot1DSnapshot.cpp b/eo/src/utils/eoGnuplot1DSnapshot.cpp index e8fb8e8cf..10dba9230 100644 --- a/eo/src/utils/eoGnuplot1DSnapshot.cpp +++ b/eo/src/utils/eoGnuplot1DSnapshot.cpp @@ -10,8 +10,8 @@ eoMonitor& eoGnuplot1DSnapshot::operator()() { // update file using the eoFileMonitor method eoFileSnapshot::operator()(); - #ifdef HAVE_GNUPLOT + // sends plot order to gnuplot std::ostringstream os; os << "set title 'Gen. " << getCounter() << "'; plot '" diff --git a/eo/src/utils/eoMonitor.h b/eo/src/utils/eoMonitor.h index 2789431dd..09360fb6e 100644 --- a/eo/src/utils/eoMonitor.h +++ b/eo/src/utils/eoMonitor.h @@ -21,7 +21,7 @@ Contact: todos@geneura.ugr.es, http://geneura.ugr.es Marc.Schoenauer@polytechnique.fr mak@dhi.dk -CVS Info: $Date: 2004-06-15 07:09:57 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/utils/eoMonitor.h,v 1.11 2004-06-15 07:09:57 evomarc Exp $ $Author: evomarc $ +CVS Info: $Date: 2007-09-05 11:36:44 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/utils/eoMonitor.h,v 1.12 2007-09-05 11:36:44 maartenkeijzer Exp $ $Author: maartenkeijzer $ */ //----------------------------------------------------------------------------- @@ -35,6 +35,7 @@ CVS Info: $Date: 2004-06-15 07:09:57 $ $Header: /home/nojhan/dev/eodev/eodev_cvs #include class eoParam; +template class eoCheckPoint; /** The abstract monitor class is a std::vector of parameter pointers. Use @@ -57,6 +58,9 @@ public : virtual std::string className(void) const { return "eoMonitor"; } + template + eoMonitor& addTo(eoCheckPoint& cp) { cp.add(*this); return *this; } + protected : typedef std::vector::iterator iterator; std::vector vec; diff --git a/eo/src/utils/eoStat.h b/eo/src/utils/eoStat.h index 06afa3fc5..5ece2686a 100644 --- a/eo/src/utils/eoStat.h +++ b/eo/src/utils/eoStat.h @@ -33,6 +33,8 @@ #include #include #include +#include +#include /** Base class for all statistics that need to be calculated @@ -49,6 +51,9 @@ public: virtual std::string className(void) const { return "eoStatBase"; } }; + +template class eoCheckPoint; + /** The actual class that will be used as base for all statistics that need to be calculated over the (unsorted) population @@ -65,6 +70,10 @@ public: virtual std::string className(void) const { return "eoStat"; } + + + eoStat& addTo(eoCheckPoint& cp) { cp.add(*this); return *this; } + eoStat& addTo(eoMonitor& mon) { mon.add(*this); return *this; } }; @@ -78,6 +87,7 @@ class eoSortedStatBase : public eoUF&, void> public: virtual void lastCall(const std::vector&) {} virtual std::string className(void) const { return "eoSortedStatBase"; } + }; /** @@ -91,6 +101,9 @@ class eoSortedStat : public eoSortedStatBase, public eoValueParam(_value, _desc) {} virtual std::string className(void) const { return "eoSortedStat"; } + + eoSortedStat& addTo(eoCheckPoint& cp) { cp.add(*this); return *this; } + eoSortedStat& addTo(eoMonitor& mon) { mon.add(*this); return *this; } }; /**