BsScriptAsyncOp.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsScriptEnginePrerequisites.h"
  5. #include "BsScriptObject.h"
  6. #include "BsAsyncOp.h"
  7. namespace BansheeEngine
  8. {
  9. /**
  10. * @brief Interop class between C++ & CLR for AsyncOp.
  11. */
  12. class BS_SCR_BE_EXPORT ScriptAsyncOp : public ScriptObject<ScriptAsyncOp>
  13. {
  14. public:
  15. SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "AsyncOp")
  16. /**
  17. * @brief Creates a new managed AsyncOp instance.
  18. *
  19. * @param op Native AsyncOp to wrap.
  20. * @param asyncOpToReturnValue Callback that converts the returned value from native async op
  21. * to a managed object.
  22. */
  23. static MonoObject* create(const AsyncOp& op, std::function<MonoObject*(const AsyncOp&)> asyncOpToReturnValue);
  24. private:
  25. ScriptAsyncOp(MonoObject* instance);
  26. /**
  27. * @brief Finishes construction of the AsyncOp wrapper. Must be called before using the object.
  28. */
  29. void initialize(const AsyncOp& op, std::function<MonoObject*(const AsyncOp&)> asyncOpToReturnValue);
  30. AsyncOp mAsyncOp;
  31. std::function<MonoObject*(const AsyncOp&)> mConvertCallback;
  32. /************************************************************************/
  33. /* CLR HOOKS */
  34. /************************************************************************/
  35. static void internal_createInstance(MonoObject* managedInstance);
  36. static void internal_isComplete(ScriptAsyncOp* thisPtr, bool* value);
  37. static MonoObject* internal_getReturnValue(ScriptAsyncOp* thisPtr);
  38. static void internal_blockUntilComplete(ScriptAsyncOp* thisPtr);
  39. };
  40. }