// -*-c++-*- #ifndef INFREQSTATEMANAGER_HH #define INFREQSTATEMANAGER_HH // Copyright (c) 1994-1996 Ohio Board of Regents and the University of // Cincinnati. All Rights Reserved. // BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY // FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT // PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, // EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE // PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME // THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. // IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING // WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR // REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR // DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL // DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM // (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED // INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF // THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER // OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. // // // $Id: InfreqStateManager.hh,v 1.1.1.1 2007/03/15 15:45:06 rmadhoun Exp $ // //--------------------------------------------------------------------------- #include "StateManager.hh" #include "FIR.cc" #include "../../../JackyDebugStream.h" class AdaptStateManager; /** The InfrequentStateManager Class. Base class for AdaptiveStateManager. */ class InfreqStateManager: public StateManager { friend class AdaptStateManager; public: /**@name Public Class Methods */ //@{ /// Constructor InfreqStateManager(BasicTimeWarp *myProcessPtr); /// Destructor ~InfreqStateManager() {}; /// create an initial state virtual void createInitialState(); /// set the state saving interval/period void setStatePeriod(int); /// retrieve the state saving interval/period int getStatePeriod() { return (statePeriod); }; #ifdef JACKY_INFREQ_STATEMANAGER //[2006-03-13] VTime getTimeAtLastCall(){ return timeAtLastCall; }; //for debugging int getPeriodCounter(){ return periodCounter; }; //for debugging //this function is used to reset timeAtLastCall = INVALIDTIME and periodCounter = 0 //after saving the initial state for each processor in LP::allRegistered() void resetTimeAtLastCallAndPeriodCounter(){ periodCounter = 0; timeAtLastCall = INVALIDTIME; } //function to set the "doStateSaving" flag void setDoStateSaving(bool doSaving){ doStateSaving = doSaving; } #endif //end JACKY_INFREQ_STATEMANAGER [2006-03-13] /// save application state //Jacky: this function overrides StateManager::saveState()! void saveState(); /// restore the correct state during rollback //Jacky: this fucntion overrides StateManager::restoreState()! VTime restoreState(VTime); // call garbage collect VTime gcollect(VTime, BasicEvent*&, Container*&); /// use time for gcollect ? ... bool useTimeForGcollect() {return (stateQ.front() )->dirty; }; //@} protected: /**@name Protected Class Attributes */ //@{ /// This is the time of the last call to save state. This is not equal to (stateQ.back() )->lVT. VTime timeAtLastCall; //@} private: /**@name Protected Class Attributes */ //@{ /// the state period with which we save state infrequently int statePeriod; /// time since the last saved state int periodCounter; #ifdef JACKY_INFREQ_STATEMANAGER //[2006-03-24] //Jacky Note: //we add a flag here to implement an extra level of state saving policy in the InfreqStateManager //If this flag is set to true, then this InfreqStateManager acts as, in effect, a StateManager. //That is, it will save state after processing every event! //its default value is false, i.e. we want to act as InfreqStateManager by default, unless we are //required by the TimeWarp object to act as normal StateManager bool doStateSaving; #endif //end JACKY_INFREQ_STATEMANAGER [2006-03-24] //@} }; #endif