source: Plugins/luaScripting/ScriptConnector.h @ 19

Revision 19, 2.1 KB checked in by art, 13 years ago (diff)
Line 
1/***************************************************************************
2 *                                                                         *
3 *   (c) Art Tevs, MPI Informatik Saarbruecken                             *
4 *       mailto: <tevs@mpi-sb.mpg.de>                                      *
5 *                                                                         *
6 *   This program is free software; you can redistribute it and/or modify  *
7 *   it under the terms of the GNU General Public License as published by  *
8 *   the Free Software Foundation; either version 2 of the License, or     *
9 *   (at your option) any later version.                                   *
10 *                                                                         *
11 ***************************************************************************/
12
13
14#ifndef _NR_LUA_CONNECTOR_H_
15#define _NR_LUA_CONNECTOR_H_
16
17//----------------------------------------------------------------------------------
18// Includes
19//----------------------------------------------------------------------------------
20#include <nrEngine/nrEngine.h>
21
22#include "Script.h"
23
24using namespace nrEngine;
25
26
27/**
28 * Glue code to connect script functions within the lua environment
29 *
30 * @see ScriptConnector
31**/
32class LuaScriptConnector : public ScriptConnector{
33
34        public:
35
36                /**
37                 * Initialize the connector
38                 **/
39                LuaScriptConnector();
40
41                /**
42                 * If any new function is registered
43                 **/
44                void OnRegisterFunction(const std::string& name, const ScriptFunctor& func);
45
46                /**
47                 * If a function was removed
48                 **/
49                void OnRemoveFunction(const std::string& name);
50
51        private:
52
53                /**
54                 * This is a wrapper function which will be called from lua.
55                 * From here the appropriate real function will be called.
56                 **/
57                static int callFunc(lua_State* L);
58
59                //! List containing already registered functions
60                std::list<std::string>  mRegistered;
61               
62                //! Include lua file (this function will be registered in lua)
63                static int includeFile(lua_State *L);
64               
65                //! Initialize default functions, which are registered in the lua environemnt
66                void initializeLuaEnvironment();
67               
68};
69
70#endif
Note: See TracBrowser for help on using the repository browser.