ScriptManager.h 1.1 KB

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