Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/ceguilua-0.5.0b/ceguilua/CEGUILuaFunctor.h @ 2698

Last change on this file since 2698 was 1810, checked in by rgrieder, 16 years ago

merged ceguilua branch back to trunk

  • Property svn:eol-style set to native
File size: 2.9 KB
RevLine 
[1803]1/***********************************************************************
2    filename: CEGUILuaFunctor.h
3    created:  Thu Jan 26 2006
4    author:   Tomas Lindquist Olsen <tomas@famolsen.dk>
5
6    purpose:  Defines interface for LuaFunctor class
7*************************************************************************/
8/***************************************************************************
9 *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10 *
11 *   Permission is hereby granted, free of charge, to any person obtaining
12 *   a copy of this software and associated documentation files (the
13 *   "Software"), to deal in the Software without restriction, including
14 *   without limitation the rights to use, copy, modify, merge, publish,
15 *   distribute, sublicense, and/or sell copies of the Software, and to
16 *   permit persons to whom the Software is furnished to do so, subject to
17 *   the following conditions:
18 *
19 *   The above copyright notice and this permission notice shall be
20 *   included in all copies or substantial portions of the Software.
21 *
22 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 *   OTHER DEALINGS IN THE SOFTWARE.
29 ***************************************************************************/
30#ifndef _CEGUILuaFunctor_h_
31#define _CEGUILuaFunctor_h_
32
33#include "CEGUIEventSet.h"
34
35struct lua_State;
36
37// Start of CEGUI namespace section
38namespace CEGUI
39{
40
41// forward declaration
42class LuaScriptModule;
43
44/*!
45\brief
46    Functor class used for subscribing Lua functions to CEGUI events
47*/
48class LuaFunctor
49{
50public:
51    LuaFunctor(lua_State* state, int func, int selfIndex);
52    LuaFunctor(lua_State* state, const String& func, int selfIndex);
53    LuaFunctor(const LuaFunctor& cp);
54    ~LuaFunctor();
55
56    bool operator()(const EventArgs& args) const;
57
58    /*!
59    \brief
60        function used to subscribe any Lua function as event handler.
61        References using the Lua registry.
62        To be called from Lua only.
63    */
64    static Event::Connection SubscribeEvent(EventSet* self, const String& eventName, int funcIndex, int selfIndex, lua_State* L);
65
66    /*!
67    \brief
68        Pushes the Lua function named \param name on top of the Lua stack.
69        The name may contain '.' (dots) character for (nested) table values.
70    */
71    static void pushNamedFunction(lua_State* L, const String& name);
72
73private:
74    lua_State* L;
75    mutable int index;
76    int self;
77    mutable bool needs_lookup;
78    mutable String function_name;
79
80    friend class LuaScriptModule;
81};
82
83} // namespace CEGUI
84
85#endif // end of guard _CEGUILuaFunctor_h_
Note: See TracBrowser for help on using the repository browser.