eoTimeContinue.h

00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003 //-----------------------------------------------------------------------------
00004 // eoTimeContinue.h
00005 // (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
00006 /*
00007     This library...
00008 
00009     Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
00010  */
00011 //-----------------------------------------------------------------------------
00012 
00013 #ifndef _EOTIMECONTINUE_H
00014 #define _EOTIMECONTINUE_H
00015 
00016 #include <eoContinue.h>
00017 
00021 template < class EOT >
00022 class eoTimeContinue: public eoContinue<EOT>
00023 {
00024 public:
00025 
00030     eoTimeContinue(time_t _max): max(_max)
00031     {
00032         start = time(NULL);
00033     }
00034 
00035 
00040     virtual bool operator() (const eoPop < EOT > & _pop)
00041     {
00042         time_t elapsed = (time_t) difftime(time(NULL), start);
00043         if (elapsed >= max)
00044         {
00045             std::cout << "STOP in eoTimeContinue: Reached maximum time [" << elapsed << "/" << max << "]" << std::endl;
00046             return false;
00047         }
00048         return true;
00049     }
00050 
00051 
00055     virtual std::string className(void) const
00056     {
00057         return "eoTimeContinue";
00058     }
00059 
00060 
00061 private:
00062 
00064     time_t max;
00066     time_t start;
00067 
00068 };
00069 
00070 #endif

Generated on Thu Apr 19 11:02:28 2007 for EO by  doxygen 1.4.7