UGDK  0.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
luawrapper.h
Go to the documentation of this file.
1 
2 #ifndef UGDK_SCRIPT_LUA_LUAWRAPPER_H_
3 #define UGDK_SCRIPT_LUA_LUAWRAPPER_H_
4 
5 #include <string>
6 #include <list>
7 #include <vector>
8 
11 
12 namespace ugdk {
13 namespace script {
14 namespace lua {
15 
16 class DataGear;
17 class LuaData;
19 
20 class LuaWrapper: public LuaWrapperBase {
21 
22  public:
23 
25  LuaWrapperBase("lua",LANG(Lua)),
26  data_gear_(NULL) {}
28  if (data_gear_) Finalize();
29  }
30 
32 
33  bool Initialize();
34 
35  void Finalize();
36 
38 
40 
41  void ExecuteCode(const std::string& code);
42 
43  VirtualObj LoadModule(const std::string& name);
44 
46 
47  VirtualData::Ptr OperateBuffer(const DataID operand_id, lua_CFunction op);
48 
49  DataGear& data_gear() { return *data_gear_; }
50 
51  void Share(DataGear* gear) {
52  data_gear_ = gear;
53  }
54 
56  return data_gear_;
57  }
58 
59  void AddToBuffer(DataID id) {
60  buffer_.push_back(id);
61  }
62 
63  void CleanBuffer() {
64  buffer_.clear();
65  }
66 
67  private:
68 
69  DataGear* data_gear_;
70  DataBuffer buffer_;
71 
72  DataID NewDataID();
73 
74  void DeleteDataID(DataID id);
75 
76  VirtualData::Ptr LoadChunk(const std::string& chunk, lua_CFunction loader);
77 
78 };
79 
80 } /* namespace lua */
81 } /* namespace script */
82 } /* namespace ugdk */
83 
84 #endif /* UGDK_SCRIPT_LUA_LUAWRAPPER_H_ */