ScriptManager.h 1003 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright (C) 2009-2015, 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. // Forward
  9. class SceneGraph;
  10. /// @addtogroup script
  11. /// @{
  12. /// The scripting manager
  13. class ScriptManager
  14. {
  15. public:
  16. #ifdef ANKI_BUILD
  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. SceneGraph& _getSceneGraph()
  25. {
  26. return *m_scene;
  27. }
  28. #endif
  29. /// Expose a variable to the scripting engine.
  30. template<typename T>
  31. void exposeVariable(const char* name, T* y)
  32. {
  33. m_lua.exposeVariable<T>(name, y);
  34. }
  35. /// Evaluate a string
  36. ANKI_USE_RESULT Error evalString(const CString& str)
  37. {
  38. return m_lua.evalString(str);
  39. }
  40. private:
  41. SceneGraph* m_scene = nullptr;
  42. ChainAllocator<U8> m_alloc;
  43. LuaBinder m_lua;
  44. };
  45. /// @}
  46. } // end namespace anki