Fawkes API  Fawkes Development Version
logreplay_thread.h
00001 
00002 /***************************************************************************
00003  *  logreplay_thread.h - BB Log Replay Thread
00004  *
00005  *  Created: Wed Feb 17 01:53:00 2010
00006  *  Copyright  2010  Tim Niemueller [www.niemueller.de]
00007  *             2010  Masrur Doostdar <doostdar@kbsg.rwth-aachen.de>
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  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL file in the doc directory.
00022  */
00023 
00024 #ifndef __PLUGINS_BBLOGGER_LOGREPLAY_THREAD_H_
00025 #define __PLUGINS_BBLOGGER_LOGREPLAY_THREAD_H_
00026 
00027 #include "bblogfile.h"
00028 
00029 #include <core/threading/thread.h>
00030 #include <aspect/logging.h>
00031 #include <aspect/configurable.h>
00032 #include <aspect/blackboard.h>
00033 #include <aspect/clock.h>
00034 #include <core/utils/lock_queue.h>
00035  
00036 #include <cstdio>
00037 
00038 namespace fawkes {
00039   class BlackBoard;
00040   class Logger;
00041   class Time;
00042 }
00043 
00044 class BBLogReplayThread
00045 : public fawkes::Thread,
00046   public fawkes::LoggingAspect,
00047   public fawkes::ConfigurableAspect,
00048   public fawkes::ClockAspect,
00049   public fawkes::BlackBoardAspect
00050 {
00051  public:
00052   BBLogReplayThread(const char *logfile_name,
00053                     const char *logdir, 
00054                     const char *scenario,
00055                     float grace_period,
00056                     bool loop_replay,
00057                     bool non_blocking = false,
00058                     const char *thread_name = "BBLogReplayThread",
00059                     fawkes::Thread::OpMode th_opmode = Thread::OPMODE_CONTINUOUS);
00060   virtual ~BBLogReplayThread();
00061 
00062   virtual void init();
00063   virtual void finalize();
00064   virtual void loop();
00065   virtual void once();
00066 
00067  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
00068  protected: virtual void run() { Thread::run(); }
00069 
00070  private:
00071   char               *__scenario;
00072   char               *__filename;
00073   char               *__logdir;
00074   char               *__logfile_name;
00075   float               __cfg_grace_period;
00076   bool                __cfg_non_blocking;
00077   bool                __cfg_loop_replay;
00078 
00079   BBLogFile          *__logfile;
00080 
00081   fawkes::Time        __last_offset;
00082   fawkes::Time        __offsetdiff;
00083   fawkes::Time        __loopdiff;
00084   fawkes::Time        __waittime;
00085   fawkes::Time        __last_loop;
00086   fawkes::Time        __now;
00087   fawkes::Interface  *__interface;
00088 };
00089 
00090 
00091 #endif