ai/lua/core.hpp

Go to the documentation of this file.
00001 /* $Id: core.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2010 - 2012 by Yurii Chernyi <terraninfo@terraninfo.net>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 #ifndef AI_LUA_CORE_HPP
00017 #define AI_LUA_CORE_HPP
00018 
00019 #include <boost/shared_ptr.hpp>
00020 
00021 struct lua_State;
00022 class LuaKernel;
00023 class config;
00024 
00025 
00026 
00027 namespace ai {
00028 
00029 class engine_lua;
00030 class lua_object_base;
00031 typedef boost::shared_ptr<lua_object_base> lua_object_ptr;
00032 
00033 /**
00034  * Proxy table for the AI context
00035  */
00036 class lua_ai_context
00037 {
00038 private:
00039     lua_State *L;
00040     int num_;
00041     int side_;
00042     lua_ai_context(lua_State *l, int num, int side) : L(l), num_(num), side_(side)
00043     {
00044     }
00045     static lua_ai_context* create(lua_State *L, char const *code, engine_lua *engine);
00046 public:
00047     ~lua_ai_context();
00048     lua_ai_context()
00049         : L(NULL)
00050         , num_(0)
00051         , side_(0)
00052     {
00053     }
00054     void load();
00055     void get_persistent_data(config &) const;
00056     void set_persistent_data(const config &);
00057     static void init(lua_State *L);
00058     friend class ::LuaKernel;
00059 };
00060 
00061 
00062 /**
00063  * Proxy class for calling AI action handlers defined in Lua.
00064  */
00065 class lua_ai_action_handler
00066 {
00067 private:
00068     lua_State *L;
00069     lua_ai_context &context_;
00070     int num_;
00071     lua_ai_action_handler(lua_State *l, lua_ai_context &context, int num) : L(l), context_(context),num_(num)
00072     {
00073     }
00074     static lua_ai_action_handler* create(lua_State *L, char const *code, lua_ai_context &context);
00075 public:
00076     ~lua_ai_action_handler();
00077     void handle(config &, bool configOut, lua_object_ptr);
00078     friend class ::LuaKernel;
00079 };
00080 
00081 }//of namespace ai
00082 
00083 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:02:30 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs