Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ScriptableController_HS17/src/orxonox/scriptablecontroller/luatb.h @ 12101

Last change on this file since 12101 was 11673, checked in by kohlia, 7 years ago

The ScriptableController should work now. A demo level called scriptableControllerTest exists as well.

File size: 1.2 KB
Line 
1#ifndef LUATB_H
2#define LUATB_H
3
4#include <string>
5
6struct lua_State;
7
8/**
9 * @brief Makes certain functions visible to lua while staying type-safe
10 * on the C++ side.
11 */
12template<typename ThisType, typename FunctionType>
13class LuaTB
14{
15public:
16    /**
17     * @brief Make a function visible to lua
18     * @param _this Pointer to the object that owns the function
19     * @param lua Pointer to the lua state
20     * @param name Name that will be visible to lua for this function
21     *
22     * Only class functions are supported, because that's  all we need at
23     * the moment. Extending it to support normal functions as well should
24     * be fairly easy, though.
25     *
26     * If you want to make a function 'Foo::bar' visible, you should call
27     * it like this (assuming no C++17 support):
28     *
29     * LuaTB<Foo, decltype(&Foo::bar)>::registerFunction<&Foo::bar>( ... );
30     */
31    template<FunctionType func>
32    static void registerFunction(ThisType *_this, lua_State *lua, std::string name);
33};
34
35// We need to include all type-dependant template implementations, because the
36// compiler needs to know for which types it has to instantiate those.
37#include "luatb.ipp"
38
39#endif // LUATB_H
Note: See TracBrowser for help on using the repository browser.