UGDK
src/ugdk/script/scriptmanager.h
Go to the documentation of this file.
00001 #ifndef UGDK_SCRIPT_SCRIPTMANAGER_H_
00002 #define UGDK_SCRIPT_SCRIPTMANAGER_H_
00003 
00004 #include <string>
00005 #include <map>
00006 
00007 #include <ugdk/script.h>
00008 
00009 namespace ugdk {
00010 
00011 namespace script {
00012 
00013 #define SCRIPT_MANAGER() (ugdk::script::ScriptManager::ref())
00014 
00015 class ScriptManager {
00016 public:
00017         static ScriptManager* ref() {
00018             return ref_ ? ref_ : ref_ = new ScriptManager;
00019         }
00020         ~ScriptManager() { ref_ = NULL; }
00021 
00022         bool Initialize();
00023         void Finalize();
00024 
00025         void Register(const std::string& name, LangWrapper* wrapper);
00026         LangWrapper* GetWrapper(const std::string& name);
00027 
00028         void ExecuteCode(const std::string& language, const std::string& code);
00029 
00030         VirtualObj LoadModule(const std::string& filepath);
00031         
00032     bool CheckIfFileExists(const std::string& filepath);
00033     
00035     std::string ConvertPathToDottedNotation(const std::string& path);
00037     std::string ConvertDottedNotationToPath(const std::string& dotted);
00038 
00039 private:
00040         static ScriptManager* ref_;
00041         ScriptManager();
00042 
00043         typedef std::map<std::string, LangWrapper*> WrapperMap;
00044         WrapperMap wrappers_;
00045 };
00046 
00047 }
00048 }
00049 
00050 #endif /* UGDK_SCRIPT_SCRIPTMANAGER_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines