00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _edoCheckPoint_h
00029 #define _edoCheckPoint_h
00030
00031 #include <utils/eoUpdater.h>
00032 #include <utils/eoMonitor.h>
00033
00034 #include "edoContinue.h"
00035 #include "edoStat.h"
00036
00038
00039 template < typename D >
00040 class edoCheckPoint : public edoContinue< D >
00041 {
00042 public:
00043 typedef typename D::EOType EOType;
00044
00045 edoCheckPoint(edoContinue< D >& _cont)
00046 {
00047 _continuators.push_back( &_cont );
00048 }
00049
00050 bool operator()(const D& distrib)
00051 {
00052 for ( unsigned int i = 0, size = _stats.size(); i < size; ++i )
00053 {
00054 (*_stats[i])( distrib );
00055 }
00056
00057 for ( unsigned int i = 0, size = _updaters.size(); i < size; ++i )
00058 {
00059 (*_updaters[i])();
00060 }
00061
00062 for ( unsigned int i = 0, size = _monitors.size(); i < size; ++i )
00063 {
00064 (*_monitors[i])();
00065 }
00066
00067 bool bContinue = true;
00068 for ( unsigned int i = 0, size = _continuators.size(); i < size; ++i )
00069 {
00070 if ( !(*_continuators[i])( distrib ) )
00071 {
00072 bContinue = false;
00073 }
00074 }
00075
00076 if ( !bContinue )
00077 {
00078 for ( unsigned int i = 0, size = _stats.size(); i < size; ++i )
00079 {
00080 _stats[i]->lastCall( distrib );
00081 }
00082
00083 for ( unsigned int i = 0, size = _updaters.size(); i < size; ++i )
00084 {
00085 _updaters[i]->lastCall();
00086 }
00087
00088 for ( unsigned int i = 0, size = _monitors.size(); i < size; ++i )
00089 {
00090 _monitors[i]->lastCall();
00091 }
00092 }
00093
00094 return bContinue;
00095 }
00096
00097 void add(edoContinue< D >& cont) { _continuators.push_back( &cont ); }
00098 void add(edoStatBase< D >& stat) { _stats.push_back( &stat ); }
00099 void add(eoMonitor& mon) { _monitors.push_back( &mon ); }
00100 void add(eoUpdater& upd) { _updaters.push_back( &upd ); }
00101
00102 virtual std::string className(void) const { return "edoCheckPoint"; }
00103
00104 std::string allClassNames() const
00105 {
00106 std::string s("\n" + className() + "\n");
00107
00108 s += "Stats\n";
00109 for ( unsigned int i = 0, size = _stats.size(); i < size; ++i )
00110 {
00111 s += _stats[i]->className() + "\n";
00112 }
00113 s += "\n";
00114
00115 s += "Updaters\n";
00116 for ( unsigned int i = 0; i < _updaters.size(); ++i )
00117 {
00118 s += _updaters[i]->className() + "\n";
00119 }
00120 s += "\n";
00121
00122 s += "Monitors\n";
00123 for ( unsigned int i = 0; i < _monitors.size(); ++i )
00124 {
00125 s += _monitors[i]->className() + "\n";
00126 }
00127 s += "\n";
00128
00129 s += "Continuators\n";
00130 for ( unsigned int i = 0, size = _continuators.size(); i < size; ++i )
00131 {
00132 s += _continuators[i]->className() + "\n";
00133 }
00134 s += "\n";
00135
00136 return s;
00137 }
00138
00139 private:
00140 std::vector< edoContinue< D >* > _continuators;
00141 std::vector< edoStatBase< D >* > _stats;
00142 std::vector< eoMonitor* > _monitors;
00143 std::vector< eoUpdater* > _updaters;
00144 };
00145
00146 #endif // !_edoCheckPoint_h