ScriptEngine.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2011 Lasse Öörni
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. #ifndef SCRIPT_SCRIPTENGINE_H
  24. #define SCRIPT_SCRIPTENGINE_H
  25. #include "RefCount.h"
  26. class asIScriptEngine;
  27. class asIScriptContext;
  28. //! Utilizes the AngelScript library for executing scripts
  29. class ScriptEngine : public RefCounted
  30. {
  31. public:
  32. //! Construct. Create the AngelScript engine and register the application interface
  33. ScriptEngine();
  34. //! Destruct. Release the AngelScript engine
  35. ~ScriptEngine();
  36. //! Create a script context
  37. asIScriptContext* createScriptContext();
  38. //! Compile and execute a line of script
  39. bool execute(const std::string& line);
  40. //! Perform garbage collection
  41. void garbageCollect();
  42. //! Return the AngelScript engine
  43. asIScriptEngine* getAngelScriptEngine() const { return mAngelScriptEngine; }
  44. //! Return immediate execution script context
  45. asIScriptContext* getImmediateContext() const { return mImmediateContext; }
  46. private:
  47. //! AngelScript engine
  48. asIScriptEngine* mAngelScriptEngine;
  49. //! Immediate execution script context
  50. asIScriptContext* mImmediateContext;
  51. };
  52. //! Return the ScriptEngine instance
  53. ScriptEngine* getScriptEngine();
  54. #endif // SCRIPT_SCRIPTENGINE_H