Fawkes API  Fawkes Development Version
logreplay_thread.h
1 
2 /***************************************************************************
3  * logreplay_thread.h - BB Log Replay Thread
4  *
5  * Created: Wed Feb 17 01:53:00 2010
6  * Copyright 2010 Tim Niemueller [www.niemueller.de]
7  * 2010 Masrur Doostdar <doostdar@kbsg.rwth-aachen.de>
8  *
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL file in the doc directory.
22  */
23 
24 #ifndef __PLUGINS_BBLOGGER_LOGREPLAY_THREAD_H_
25 #define __PLUGINS_BBLOGGER_LOGREPLAY_THREAD_H_
26 
27 #include "bblogfile.h"
28 
29 #include <core/threading/thread.h>
30 #include <aspect/logging.h>
31 #include <aspect/configurable.h>
32 #include <aspect/blackboard.h>
33 #include <aspect/clock.h>
34 #include <core/utils/lock_queue.h>
35 
36 #include <cstdio>
37 
38 namespace fawkes {
39  class BlackBoard;
40  class Logger;
41  class Time;
42 }
43 
45 : public fawkes::Thread,
46  public fawkes::LoggingAspect,
48  public fawkes::ClockAspect,
50 {
51  public:
52  BBLogReplayThread(const char *logfile_name,
53  const char *logdir,
54  const char *scenario,
55  float grace_period,
56  bool loop_replay,
57  bool non_blocking = false,
58  const char *thread_name = "BBLogReplayThread",
60  virtual ~BBLogReplayThread();
61 
62  virtual void init();
63  virtual void finalize();
64  virtual void loop();
65  virtual void once();
66 
67  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
68  protected: virtual void run() { Thread::run(); }
69 
70  private:
71  char *__scenario;
72  char *__filename;
73  char *__logdir;
74  char *__logfile_name;
75  float __cfg_grace_period;
76  bool __cfg_non_blocking;
77  bool __cfg_loop_replay;
78 
79  BBLogFile *__logfile;
80 
81  fawkes::Time __last_offset;
82  fawkes::Time __offsetdiff;
83  fawkes::Time __loopdiff;
84  fawkes::Time __waittime;
85  fawkes::Time __last_loop;
86  fawkes::Time __now;
87  fawkes::Interface *__interface;
88 };
89 
90 
91 #endif
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:36
Fawkes library namespace.
virtual void run()
Code to execute in the thread.
Definition: thread.cpp:939
OpMode
Thread operation mode.
Definition: thread.h:52
A class for handling time.
Definition: time.h:91
Thread class encapsulation of pthreads.
Definition: thread.h:42
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
operate in continuous mode (default)
Definition: thread.h:53
Thread aspect to log output.
Definition: logging.h:35
virtual void run()
Stub to see name in backtrace for easier debugging.
Thread aspect to access configuration data.
Definition: configurable.h:35
Class to easily access bblogger log files.
Definition: bblogfile.h:38
BlackBoard log Replay thread.