ScriptManager.h 988 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. /// @addtogroup script
  12. /// @{
  13. /// The scripting manager
  14. class ScriptManager
  15. {
  16. public:
  17. /// Expose a variable to the scripting engine.
  18. template<typename T>
  19. void exposeVariable(const char* name, T* y)
  20. {
  21. m_lua.exposeVariable<T>(name, y);
  22. }
  23. /// Evaluate a string
  24. ANKI_USE_RESULT Error evalString(const CString& str)
  25. {
  26. return m_lua.evalString(str);
  27. }
  28. anki_internal:
  29. ScriptManager();
  30. ~ScriptManager();
  31. /// Create the script manager.
  32. ANKI_USE_RESULT Error create(
  33. AllocAlignedCallback allocCb, void* allocCbData, SceneGraph* scene);
  34. SceneGraph& _getSceneGraph()
  35. {
  36. return *m_scene;
  37. }
  38. private:
  39. SceneGraph* m_scene = nullptr;
  40. ChainAllocator<U8> m_alloc;
  41. LuaBinder m_lua;
  42. };
  43. /// @}
  44. } // end namespace anki