UGDK  0.5.0
 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), "Lua"),
26  data_gear_(nullptr) {}
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 std::string NameConversion(const std::string& name);
81 
82 } /* namespace lua */
83 } /* namespace script */
84 } /* namespace ugdk */
85 
86 #endif /* UGDK_SCRIPT_LUA_LUAWRAPPER_H_ */
DataGear * shared_gear()
Definition: luawrapper.h:55
~LuaWrapper()
Definition: luawrapper.h:27
Definition: luadata.h:16
Definition: luawrapper.h:20
std::string NameConversion(const std::string &name)
Definition: animation.h:11
std::shared_ptr< VirtualData > Ptr
Definition: virtualdata.h:46
void CleanBuffer()
Definition: luawrapper.h:63
std::list< DataID > DataBuffer
Definition: defs.h:21
void ExecuteCode(const std::string &code)
DataGear & data_gear()
Definition: luawrapper.h:49
void Share(DataGear *gear)
Definition: luawrapper.h:51
VirtualData::Ptr NewData()
void AddToBuffer(DataID id)
Definition: luawrapper.h:59
Definition: datagear.h:16
bool Initialize()
Overwritten methods.
void Finalize()
Finalizes the LangWrapper, finalizing any language specific stuff.
int(* lua_CFunction)(lua_State *)
Definition: defs.h:9
#define LANG(name)
Here are the common definitions of the script system.
Definition: defs.h:7
LuaWrapper()
Definition: luawrapper.h:24
A proxy class wich represents virtual objects from scripting languages.
Definition: virtualobj.h:30
ugdk::script::InheritableLangWrapper< lua_CFunction > LuaWrapperBase
Definition: luawrapper.h:17
VirtualObj LoadModule(const std::string &name)
VirtualData::Ptr OperateBuffer(const DataID operand_id, lua_CFunction op)
Other methods.
int DataID
Definition: defs.h:20
Wraps a scripting language.
Definition: script.h:15