i6engine  1.0
ScriptingFacade.h
Go to the documentation of this file.
1 /*
2  * i6engine
3  * Copyright (2016) Daniel Bonrath, Michael Baer, All rights reserved.
4  *
5  * This file is part of i6engine; i6engine is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
25 #ifndef __I6ENGINE_API_SCRIPTINGFACADE_H__
26 #define __I6ENGINE_API_SCRIPTINGFACADE_H__
27 
28 #include <cstdint>
29 #include <string>
30 
32 
33 #if ISIXE_SCRIPTING == SCRIPTING_LUA
35 #elif ISIXE_SCRIPTING == SCRIPTING_PYTHON
37 #endif
38 
39 namespace i6e {
40 namespace api {
41 
43 #if ISIXE_SCRIPTING == SCRIPTING_LUA
45 #elif ISIXE_SCRIPTING == SCRIPTING_PYTHON
47 #endif
48 
49  public:
51  ~ScriptingFacade();
52 
56  void loadAllScripts() const;
57 
58 #if ISIXE_SCRIPTING != SCRIPTING_NONE
59 
62  template<typename Ret, typename... args>
63  typename std::enable_if<std::is_void<Ret>::value, Ret>::type callScript(const std::string & file, const std::string & func, args... B) {
64  _manager->callScript<Ret>(file, func, B...);
65  }
66 
70  template<typename Ret, typename... args>
71  typename std::enable_if<!std::is_void<Ret>::value, std::shared_ptr<utils::Future<Ret>>>::type callScript(const std::string & file, const std::string & func, args... B) {
72  return _manager->callScript<Ret>(file, func, B...);
73  }
74 
78  template<typename Ret, typename... args>
79  typename std::enable_if<std::is_void<Ret>::value, Ret>::type callFunction(const std::string & func, args... B) {
80  _manager->callFunction<Ret>(func, B...);
81  }
82 
86  template<typename Ret, typename... args>
87  typename std::enable_if<!std::is_void<Ret>::value, std::shared_ptr<utils::Future<Ret>>>::type callFunction(const std::string & func, args... B) {
88  return _manager->callFunction<Ret>(func, B...);
89  }
90 
94  template<typename Ret, typename... args>
95  typename std::enable_if<std::is_void<Ret>::value, Ret>::type callScriptWithCallback(const std::string & file, const std::string & func, const std::function<void(void)> & callback, args... B) {
96  _manager->callScriptWithCallback<Ret>(file, func, callback, B...);
97  }
98 
102  template<typename Ret, typename... args>
103  typename std::enable_if<!std::is_void<Ret>::value, std::shared_ptr<utils::Future<Ret>>>::type callScriptWithCallback(const std::string & file, const std::string & func, const std::function<void(void)> & callback, args... B) {
104  return _manager->callScriptWithCallback<Ret>(file, func, callback, B...);
105  }
106 
110  template<typename Ret, typename... args>
111  typename std::enable_if<std::is_void<Ret>::value, Ret>::type callFunctionWithCallback(const std::string & func, const std::function<void(void)> & callback, args... B) {
112  _manager->callFunctionWithCallback<Ret>(func, callback, B...);
113  }
114 
118  template<typename Ret, typename... args>
119  typename std::enable_if<!std::is_void<Ret>::value, std::shared_ptr<utils::Future<Ret>>>::type callFunctionWithCallback(const std::string & func, const std::function<void(void)> & callback, args... B) {
120  return _manager->callFunction<Ret>(func, callback, B...);
121  }
122 
126  template<typename T>
127  typename std::enable_if<std::is_pointer<T>::value>::type setGlobalVariable(const std::string & name, T value) {
128  _manager->setGlobalVariable(name, value);
129  }
130 #endif
131 
135  void resetSubSystem();
136 
137  private:
138 #if ISIXE_SCRIPTING == SCRIPTING_LUA
139  modules::LuaScriptingManager * _manager;
140 #elif ISIXE_SCRIPTING == SCRIPTING_PYTHON
141  modules::PythonScriptingManager * _manager;
142 #endif
143 
147  ScriptingFacade(const ScriptingFacade &) = delete;
148 
152  ScriptingFacade & operator=(const ScriptingFacade &) = delete;
153  };
154 
155 } /* namespace api */
156 } /* namespace i6e */
157 
158 #endif /* __I6ENGINE_API_SCRIPTINGFACADE_H__ */
159 
#define ISIXE_MODULES_API