Fawkes API  Fawkes Development Version
exec_thread.h
1 
2 /***************************************************************************
3  * exec_thread.h - Fawkes Skiller: Execution Thread
4  *
5  * Created: Mon Feb 18 10:28:38 2008
6  * Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef _PLUGINS_SKILLER_EXEC_THREAD_H_
24 #define _PLUGINS_SKILLER_EXEC_THREAD_H_
25 
26 #include <aspect/blackboard.h>
27 #include <aspect/blocked_timing.h>
28 #include <aspect/clock.h>
29 #include <aspect/configurable.h>
30 #include <aspect/logging.h>
31 #include <core/threading/thread.h>
32 #ifdef HAVE_TF
33 # include <aspect/tf.h>
34 #endif
35 #include <blackboard/interface_listener.h>
36 #include <blackboard/ownership.h>
37 #include <core/utils/lock_queue.h>
38 #include <lua/context_watcher.h>
39 #include <utils/system/fam.h>
40 
41 #include <cstdlib>
42 #include <list>
43 #include <string>
44 
45 namespace fawkes {
46 class ComponentLogger;
47 class Mutex;
48 class LuaContext;
49 class Interface;
50 class SkillerInterface;
51 class SkillerDebugInterface;
52 #ifdef SKILLER_TIMETRACKING
53 class TimeTracker;
54 #endif
55 } // namespace fawkes
56 class SkillerFeature;
57 
60  public fawkes::LoggingAspect,
63  public fawkes::ClockAspect,
64 #ifdef HAVE_TF
66 #endif
69 {
70 public:
72  virtual ~SkillerExecutionThread();
73 
74  virtual void init();
75  virtual void loop();
76  virtual void finalize();
77 
78  void add_skiller_feature(SkillerFeature *feature);
79 
80  /* BlackBoardInterfaceListener */
82  unsigned int instance_serial) throw();
83 
84  // LuaContextWatcher
85  void lua_restarted(fawkes::LuaContext *context);
86 
87  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
88 protected:
89  virtual void
90  run()
91  {
92  Thread::run();
93  }
94 
95 private: /* members */
98 
99  // config values
100  std::string cfg_skillspace_;
101  bool cfg_watch_files_;
102 
103  fawkes::LockQueue<unsigned int> skiller_if_removed_readers_;
104 
105  fawkes::SkillerInterface *skiller_if_;
106 
107  fawkes::LuaContext *lua_;
108 
109  std::list<SkillerFeature *> features_;
110 };
111 
112 #endif
SkillerExecutionThread
Definition: exec_thread.h:57
SkillerExecutionThread::SkillerExecutionThread
SkillerExecutionThread()
Constructor.
Definition: exec_thread.cpp:56
fawkes::LuaContext
Definition: context.h:47
SkillerExecutionThread::bb_interface_reader_removed
void bb_interface_reader_removed(fawkes::Interface *interface, unsigned int instance_serial)
A reading instance has been closed for a watched interface.
Definition: exec_thread.cpp:210
fawkes::ComponentLogger
Definition: component.h:39
fawkes::BlackBoardInterfaceListener
Definition: interface_listener.h:45
fawkes::LuaContextWatcher
Definition: context_watcher.h:34
fawkes::BlockedTimingAspect
Definition: blocked_timing.h:54
SkillerExecutionThread::add_skiller_feature
void add_skiller_feature(SkillerFeature *feature)
Add a skiller feature.
Definition: exec_thread.cpp:171
fawkes::BlackBoardAspect
Definition: blackboard.h:36
fawkes
fawkes::LoggingAspect
Definition: logging.h:36
SkillerExecutionThread::lua_restarted
void lua_restarted(fawkes::LuaContext *context)
Definition: exec_thread.cpp:177
fawkes::TransformAspect
Definition: tf.h:41
fawkes::Interface
Definition: interface.h:77
fawkes::SkillerInterface
Definition: SkillerInterface.h:37
SkillerExecutionThread::init
virtual void init()
Initialize the thread.
Definition: exec_thread.cpp:69
SkillerFeature
Definition: skiller_feature.h:31
fawkes::LockQueue< unsigned int >
fawkes::BlackBoardWithOwnership
Definition: ownership.h:33
SkillerExecutionThread::loop
virtual void loop()
Code to execute in the thread.
Definition: exec_thread.cpp:217
fawkes::Thread
Definition: thread.h:44
SkillerExecutionThread::run
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: exec_thread.h:89
fawkes::ConfigurableAspect
Definition: configurable.h:36
fawkes::ClockAspect
Definition: clock.h:38
SkillerExecutionThread::~SkillerExecutionThread
virtual ~SkillerExecutionThread()
Destructor.
Definition: exec_thread.cpp:64
SkillerExecutionThread::finalize
virtual void finalize()
Finalize the thread.
Definition: exec_thread.cpp:148