UGDK  0.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
scriptmanager.h
Go to the documentation of this file.
1 #ifndef UGDK_SCRIPT_SCRIPTMANAGER_H_
2 #define UGDK_SCRIPT_SCRIPTMANAGER_H_
3 
4 #include <string>
5 #include <map>
6 
7 #include <ugdk/script.h>
8 
9 namespace ugdk {
10 
11 namespace script {
12 
13 #define SCRIPT_MANAGER() (ugdk::script::ScriptManager::ref())
14 
16 public:
17  static ScriptManager* ref() {
18  return ref_ ? ref_ : ref_ = new ScriptManager;
19  }
20  ~ScriptManager() { ref_ = NULL; }
21 
22  bool Initialize();
23  void Finalize();
24 
25  void Register(const std::string& name, LangWrapper* wrapper);
26  LangWrapper* GetWrapper(const std::string& name);
27 
28  void ExecuteCode(const std::string& language, const std::string& code);
29 
30  VirtualObj LoadModule(const std::string& filepath);
31 
32  bool CheckIfFileExists(const std::string& filepath);
33 
35  std::string ConvertPathToDottedNotation(const std::string& path);
37  std::string ConvertDottedNotationToPath(const std::string& dotted);
38 
39 private:
40  static ScriptManager* ref_;
41  ScriptManager();
42 
43  typedef std::map<std::string, LangWrapper*> WrapperMap;
44  WrapperMap wrappers_;
45 };
46 
47 }
48 }
49 
50 #endif /* UGDK_SCRIPT_SCRIPTMANAGER_H_ */