Fawkes API Fawkes Development Version
continuous_exec_thread.h
1
2/***************************************************************************
3 * continuous_exec_thread.h - Fawkes LuaAgent: Continuous Execution Thread
4 *
5 * Created: Thu May 26 11:49:17 2011
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_LUAAGENT_CONTINUOUS_EXEC_THREAD_H_
24#define _PLUGINS_LUAAGENT_CONTINUOUS_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 <aspect/thread_producer.h>
32#include <core/threading/thread.h>
33#ifdef HAVE_TF
34# include <aspect/tf.h>
35#endif
36#include <utils/system/fam.h>
37
38#include <cstdlib>
39#include <string>
40
41namespace fawkes {
42class ComponentLogger;
43class Mutex;
44class LuaContext;
45class LuaInterfaceImporter;
46class Interface;
47class SkillerInterface;
48class SkillerDebugInterface;
49} // namespace fawkes
50
58#ifdef HAVE_TF
60#endif
62{
63public:
66
67 virtual void init();
68 virtual void loop();
69 virtual void finalize();
70
71 virtual void fam_event(const char *filename, unsigned int mask);
72
73 void read_interfaces();
74 void write_interfaces();
75
76 /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
77protected:
78 virtual void
80 {
81 Thread::run();
82 }
83
84private: /* methods */
85 void init_failure_cleanup();
86
87 class LuaThread : public Thread, public fawkes::LoggingAspect
88 {
89 public:
90 LuaThread(fawkes::LuaContext *lua);
91 virtual void loop();
92
93 /** Check if LuaThread failed.
94 * @return true if an error occured, false otherwise. */
95 bool
96 failed()
97 {
98 return failed_;
99 }
100
101 private:
102 fawkes::LuaContext *lua_;
103 bool failed_;
104 };
105
106private: /* members */
108
109 // config values
110 std::string cfg_agent_;
111 bool cfg_watch_files_;
112
113 fawkes::SkillerInterface *skiller_if_;
114
115 fawkes::LuaContext * lua_;
117
118 fawkes::Mutex *ifi_mutex_;
119 LuaThread * lua_thread_;
120};
121
122#endif
LuaAgent Periodic Execution Thread.
virtual void run()
Stub to see name in backtrace for easier debugging.
void write_interfaces()
Update all reading interfaces.
virtual void fam_event(const char *filename, unsigned int mask)
Event has been raised.
virtual void init()
Initialize the thread.
virtual void finalize()
Finalize the thread.
virtual ~LuaAgentContinuousExecutionThread()
Destructor.
virtual void loop()
Code to execute in the thread.
void read_interfaces()
Update all reading interfaces.
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect to use blocked timing.
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:34
Component logger.
Definition: component.h:36
Thread aspect to access configuration data.
Definition: configurable.h:33
File Alteration Monitor Listener.
Definition: fam.h:36
Thread aspect to log output.
Definition: logging.h:33
Lua C++ wrapper.
Definition: context.h:44
Lua interface importer.
Mutex mutual exclusion lock.
Definition: mutex.h:33
SkillerInterface Fawkes BlackBoard Interface.
Aspect for thread producing threads.
Thread class encapsulation of pthreads.
Definition: thread.h:46
Thread(const char *name)
Constructor.
Definition: thread.cpp:204
Thread aspect to access the transform system.
Definition: tf.h:39
Fawkes library namespace.