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 <aspect/blackboard.h>
30 #include <aspect/clock.h>
31 #include <aspect/configurable.h>
32 #include <aspect/logging.h>
33 #include <core/threading/thread.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 } // namespace fawkes
43 
45  public fawkes::LoggingAspect,
47  public fawkes::ClockAspect,
49 {
50 public:
51  BBLogReplayThread(const char * logfile_name,
52  const char * logdir,
53  const char * scenario,
54  float grace_period,
55  bool loop_replay,
56  bool non_blocking = false,
57  const char * thread_name = "BBLogReplayThread",
58  fawkes::Thread::OpMode th_opmode = Thread::OPMODE_CONTINUOUS);
59  virtual ~BBLogReplayThread();
60 
61  virtual void init();
62  virtual void finalize();
63  virtual void loop();
64  virtual void once();
65 
66  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
67 protected:
68  virtual void
69  run()
70  {
71  Thread::run();
72  }
73 
74 private:
75  char *scenario_;
76  char *filename_;
77  char *logdir_;
78  char *logfile_name_;
79  float cfg_grace_period_;
80  bool cfg_non_blocking_;
81  bool cfg_loop_replay_;
82 
83  BBLogFile *logfile_;
84 
85  fawkes::Time last_offset_;
86  fawkes::Time offsetdiff_;
87  fawkes::Time loopdiff_;
88  fawkes::Time waittime_;
89  fawkes::Time last_loop_;
90  fawkes::Time now_;
91  fawkes::Interface *interface_;
92 };
93 
94 #endif
virtual void init()
Initialize the thread.
Thread aspect to access to BlackBoard.
Definition: blackboard.h:33
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:33
virtual ~BBLogReplayThread()
Destructor.
Fawkes library namespace.
OpMode
Thread operation mode.
Definition: thread.h:56
A class for handling time.
Definition: time.h:92
Thread class encapsulation of pthreads.
Definition: thread.h:45
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:78
BBLogReplayThread(const char *logfile_name, const char *logdir, const char *scenario, float grace_period, bool loop_replay, bool non_blocking=false, const char *thread_name="BBLogReplayThread", fawkes::Thread::OpMode th_opmode=Thread::OPMODE_CONTINUOUS)
Constructor.
Thread aspect to log output.
Definition: logging.h:32
virtual void run()
Stub to see name in backtrace for easier debugging.
virtual void once()
Execute an action exactly once.
Thread aspect to access configuration data.
Definition: configurable.h:32
virtual void loop()
Code to execute in the thread.
virtual void finalize()
Finalize the thread.
Class to easily access bblogger log files.
Definition: bblogfile.h:39
BlackBoard log Replay thread.