UGDK
src/ugdk/script/languages/lua/luawrapper.h
Go to the documentation of this file.
00001 
00002 #ifndef UGDK_SCRIPT_LUA_LUAWRAPPER_H_
00003 #define UGDK_SCRIPT_LUA_LUAWRAPPER_H_
00004 
00005 #include <string>
00006 #include <list>
00007 #include <vector>
00008 
00009 #include <ugdk/script/languages/lua/defs.h>
00010 #include <ugdk/script/langwrapper.h>
00011 
00012 namespace ugdk {
00013 namespace script {
00014 namespace lua {
00015 
00016 class DataGear;
00017 class LuaData;
00018 typedef ugdk::script::InheritableLangWrapper<lua_CFunction> LuaWrapperBase;
00019 
00020 class LuaWrapper: public LuaWrapperBase {
00021 
00022   public:
00023 
00024     LuaWrapper() :
00025         LuaWrapperBase("lua",LANG(Lua)),
00026         data_gear_(NULL) {}
00027     ~LuaWrapper() {
00028         if (data_gear_) Finalize();
00029     }
00030 
00032 
00033     bool Initialize();
00034 
00035     void Finalize();
00036 
00037     VirtualData::Ptr NewData();
00038 
00039     LuaData* NewLuaData();
00040 
00041     void ExecuteCode(const std::string& code);
00042 
00043     VirtualObj LoadModule(const std::string& name);
00044 
00046 
00047     VirtualData::Ptr OperateBuffer(const DataID operand_id, lua_CFunction op);
00048 
00049     DataGear& data_gear() { return *data_gear_; }
00050 
00051     void Share(DataGear* gear) {
00052         data_gear_ = gear;
00053     }
00054 
00055     DataGear* shared_gear() {
00056         return data_gear_;
00057     }
00058 
00059     void AddToBuffer(DataID id) {
00060         buffer_.push_back(id);
00061     }
00062 
00063     void CleanBuffer() {
00064         buffer_.clear();
00065     }
00066 
00067   private:
00068 
00069     DataGear*   data_gear_;
00070     DataBuffer  buffer_;
00071 
00072     DataID NewDataID();
00073 
00074     void DeleteDataID(DataID id);
00075 
00076     VirtualData::Ptr LoadChunk(const std::string& chunk, lua_CFunction loader);
00077 
00078 };
00079 
00080 } /* namespace lua */
00081 } /* namespace script */
00082 } /* namespace ugdk */
00083 
00084 #endif /* UGDK_SCRIPT_LUA_LUAWRAPPER_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines