00001 /***************************************************************************
00002 ticktock.cpp - description
00003 -------------------
00004 begin : Tue Aug 12 2000
00005 copyright : (C) 2000 by Michael Peeters
00006 email : Michael.Peeters@vub.ac.be
00007 ***************************************************************************/
00008
00009 /***************************************************************************
00010 * *
00011 * This program is free software; you can redistribute it and/or modify *
00012 * it under the terms of the GNU General Public License as published by *
00013 * the Free Software Foundation; either version 2 of the License, or *
00014 * (at your option) any later version. *
00015 * *
00016 ***************************************************************************/
00017
00018 #include "ticktock.h"
00019
00020 namespace MODEL
00021 {
00022 TickTock::TickTock(TimeFrame& T,time resolution) :
00023 TimeFrame(resolution),Cycler(T),resmatch(0)
00024 {
00025 // This recalibrates the resolution to a whole fraction of the timeframe
00026 time big_dt=T.get_dt();
00027 resmatch=counter(big_dt/dt);
00028 dt=(big_dt/number(resmatch));
00029 }
00030
00031 TimeFrame&
00032 TickTock::get_timeframe(void)
00033 {
00034 return *dynamic_cast<TimeFrame*>(get_boss());
00035 }
00036
00037 void
00038 TickTock::execute(void)
00039 {
00040 // Ooooooh you dirty ... !
00041 // But of course it is the ticktock which is responsible,
00042 // as it can only be added to a TimeFrame. The TimeFrame,
00043 // on the other hand, does not know what kind of objects
00044 // is it calling
00045 t = dynamic_cast<TimeFrame*>(get_boss())->get_time();
00046
00047 for(counter repeat=get_resmatch();repeat>0;--repeat)
00048 {
00049 tick();
00050 // Update time - don't worry:local time only
00051 // t+=dt;
00053 }
00054 }
00055
00056 }
00057
00058 /*********************************************************************
00059 $Id: ticktock.cpp,v 1.2 2001/07/26 12:02:24 mpeeters Exp $
00060 **********************************************************************
00061
00062 $Log: ticktock.cpp,v $
00063 Revision 1.2 2001/07/26 12:02:24 mpeeters
00064 Removed nasty bug where time would run backwards in certain cases (see todo list).
00065
00066 Revision 1.1 2001/05/22 10:54:55 mpeeters
00067 Moved sources and headers for libModel to model/ subdirectory, in an attempt to rationalize the source tree. This should make things "netter".
00068
00069 Revision 1.2 2000/09/15 10:26:31 mpeeters
00070 Cleaned out header and added CVS tails to files, removed superfuous
00071 @author comments, inserted dates
00072
00073 *********************************************************************/
More Info? Michael Peeters. Also, check our research website: www.alna.vub.ac.be
Last update: June 2002.