EvolvingObjects
eoUpdater.cpp
00001 #ifdef _MSC_VER
00002 #pragma warning(disable:4786)
00003 #endif
00004 
00005 #ifdef HAVE_CONFIG_H
00006 #include <config.h>
00007 #endif
00008 
00009 #include <sstream>
00010 
00011 #include <utils/eoState.h>
00012 #include <utils/eoUpdater.h>
00013 
00014 using namespace std;
00015 
00016 void eoTimedStateSaver::operator()(void)
00017 {
00018     time_t now = time(0);
00019 
00020     if (now >= last_time + interval)
00021     {
00022         last_time = now;
00023         ostringstream os;
00024         os << prefix << (now - first_time) << '.' << extension;
00025         state.save(os.str());
00026     }
00027 }
00028 
00029 void eoCountedStateSaver::doItNow(void)
00030 {
00031         ostringstream os;
00032         os << prefix << counter << '.' << extension;
00033         state.save(os.str());
00034 }
00035 
00036 void eoCountedStateSaver::operator()(void)
00037 {
00038     if (++counter % interval == 0)
00039       doItNow();
00040 }
00041 
00042 void eoCountedStateSaver::lastCall(void)
00043 {
00044     if (saveOnLastCall)
00045       doItNow();
00046 }
 All Classes Namespaces Files Functions Variables Typedefs Friends