ScriptManager.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright (C) 2014, Panagiotis Christopoulos Charitos.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #ifndef ANKI_SCRIPT_SCRIPT_MANAGER_H
  6. #define ANKI_SCRIPT_SCRIPT_MANAGER_H
  7. #include "anki/script/LuaBinder.h"
  8. namespace anki {
  9. // Forward
  10. class SceneGraph;
  11. /// @addtogroup script
  12. /// @{
  13. /// The scripting manager
  14. class ScriptManager
  15. {
  16. public:
  17. ScriptManager();
  18. ~ScriptManager();
  19. /// Create the script manager.
  20. ANKI_USE_RESULT Error create(
  21. AllocAlignedCallback allocCb,
  22. void* allocCbData,
  23. SceneGraph* scene);
  24. /// Expose a variable to the scripting engine.
  25. template<typename T>
  26. void exposeVariable(const char* name, T* y)
  27. {
  28. m_lua.exposeVariable<T>(name, y);
  29. }
  30. /// Evaluate a string
  31. ANKI_USE_RESULT Error evalString(const CString& str)
  32. {
  33. return m_lua.evalString(str);
  34. }
  35. /// @privatesection
  36. /// @{
  37. SceneGraph& _getSceneGraph()
  38. {
  39. return *m_scene;
  40. }
  41. /// @}
  42. public:
  43. SceneGraph* m_scene = nullptr;
  44. ChainAllocator<U8> m_alloc;
  45. LuaBinder m_lua;
  46. };
  47. /// @}
  48. } // end namespace anki
  49. #endif