Fawkes API Fawkes Development Version
skiller_navgraph_feature.cpp
1/***************************************************************************
2 * skiller_navgraph_thread.cpp - Optional skiller access to navgraph
3 *
4 * Created: Wed Jul 16 13:03:25 2014 (on flight to Joao Pessoa)
5 * Copyright 2012-2014 Tim Niemueller [www.niemueller.de]
6 ****************************************************************************/
7
8/* This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Library General Public License for more details.
17 *
18 * Read the full text in the LICENSE.GPL file in the doc directory.
19 */
20
21#include "skiller_navgraph_feature.h"
22
23#include <lua/context.h>
24#include <navgraph/yaml_navgraph.h>
25
26using namespace fawkes;
27
28/** @class SkillerNavGraphFeature "skiller_navgraph_feature.h"
29 * Thread to access the navgraph from skiller.
30 * The thread itself does not perform any actions. But splitting it into its
31 * own thread will allow us to make access to the navgraph optional. So if
32 * the graph is not required the navgraph module does not have to be loaded.
33 * @author Tim Niemueller
34 */
35
36/** Constructor. */
38: Thread("SkillerNavGraphFeature", Thread::OPMODE_WAITFORWAKEUP)
39{
40}
41
42/** Destructor. */
44{
45}
46
47void
49{
50}
51
52void
54{
55}
56
57void
59{
60}
61
62void
64{
65 logger->log_info(name(), "Intializing navgraph for skiller");
66 context->add_package("fawkesnavgraph");
67 context->get_global("features_env_template");
68 context->push_string("navgraph");
69 context->push_usertype(*navgraph, "NavGraph", "fawkes");
70 context->set_table();
71}
72
73void
75{
76 logger->log_info(name(), "Finalizing navgraph for skiller");
77 context->get_global("features_env_template");
78 context->push_string("navgraph");
79 context->push_nil();
80 context->set_table();
81}
virtual void loop()
Code to execute in the thread.
virtual void init_lua_context(fawkes::LuaContext *context)
Initialize a Lua context.
virtual void init()
Initialize the thread.
virtual void finalize_lua_context(fawkes::LuaContext *context)
Finalize a Lua context.
virtual void finalize()
Finalize the thread.
virtual ~SkillerNavGraphFeature()
Destructor.
virtual void log_info(const char *component, const char *format,...)=0
Log informational message.
Logger * logger
This is the Logger member used to access the logger.
Definition: logging.h:41
Lua C++ wrapper.
Definition: context.h:44
void push_string(const char *value)
Push string on top of stack.
Definition: context.cpp:839
void push_nil()
Push nil on top of stack.
Definition: context.cpp:819
void get_global(const char *name)
Get global variable.
Definition: context.cpp:1068
void push_usertype(void *data, const char *type_name, const char *name_space=0)
Push usertype on top of stack.
Definition: context.cpp:882
void set_table(int t_index=-3)
Set value of a table.
Definition: context.cpp:966
void add_package(const char *package)
Add a default package.
Definition: context.cpp:386
fawkes::LockPtr< NavGraph > navgraph
NavGraph instance shared in framework.
Definition: navgraph.h:44
Thread class encapsulation of pthreads.
Definition: thread.h:46
const char * name() const
Get name of thread.
Definition: thread.h:100
Fawkes library namespace.