BsScriptAsyncOp.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 bs
  8. {
  9. /** @addtogroup ScriptInteropEngine
  10. * @{
  11. */
  12. /** Interop class between C++ & CLR for AsyncOp. */
  13. class BS_SCR_BE_EXPORT ScriptAsyncOp : public ScriptObject<ScriptAsyncOp>
  14. {
  15. public:
  16. SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "AsyncOp")
  17. /**
  18. * Creates a new managed AsyncOp instance.
  19. *
  20. * @param[in] op Native AsyncOp to wrap.
  21. * @param[in] asyncOpToReturnValue Callback that converts the returned value from native async op to a managed
  22. * object.
  23. */
  24. static MonoObject* create(const AsyncOp& op, std::function<MonoObject*(const AsyncOp&)> asyncOpToReturnValue);
  25. private:
  26. ScriptAsyncOp(MonoObject* instance);
  27. /** Finishes construction of the AsyncOp wrapper. Must be called before using the object. */
  28. void initialize(const AsyncOp& op, std::function<MonoObject*(const AsyncOp&)> asyncOpToReturnValue);
  29. AsyncOp mAsyncOp;
  30. std::function<MonoObject*(const AsyncOp&)> mConvertCallback;
  31. /************************************************************************/
  32. /* CLR HOOKS */
  33. /************************************************************************/
  34. static void internal_createInstance(MonoObject* managedInstance);
  35. static void internal_isComplete(ScriptAsyncOp* thisPtr, bool* value);
  36. static MonoObject* internal_getReturnValue(ScriptAsyncOp* thisPtr);
  37. static void internal_blockUntilComplete(ScriptAsyncOp* thisPtr);
  38. };
  39. /** @} */
  40. }