GlowProcess.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // Copyright (c) 2014-2017 THUNDERBEAST GAMES LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #include <Atomic/IPC/IPCServer.h>
  23. using namespace Atomic;
  24. namespace AtomicGlow
  25. {
  26. class GlowProcessResultHandler;
  27. class GlowProcess : public IPCServer
  28. {
  29. friend class GlowProcessResultHandler;
  30. ATOMIC_OBJECT(GlowProcess, IPCServer)
  31. public:
  32. /// Construct.
  33. GlowProcess(Context* context);
  34. /// Destruct.
  35. virtual ~GlowProcess();
  36. bool Start() { return false; }
  37. bool Start(const String& glowBinaryPath, const StringVector& baseArgs);
  38. void Exit();
  39. bool GetExitCalled() const { return exitCalled_; }
  40. unsigned QueueCommand(const VariantMap& cmdMap);
  41. private:
  42. void OnIPCWorkerLog(int level, const String& message);
  43. void OnIPCWorkerExited();
  44. void HandleResult(unsigned cmdID, const VariantMap& cmdResult);
  45. void HandleAtomicGlowResult(StringHash eventType, VariantMap& eventData);
  46. bool exitCalled_;
  47. SharedPtr<GlowProcessResultHandler> resultHandler_;
  48. };
  49. class GlowProcessResultHandler : public IPCResultHandler
  50. {
  51. ATOMIC_OBJECT(GlowProcessResultHandler, IPCResultHandler)
  52. public:
  53. /// Construct.
  54. GlowProcessResultHandler(Context* context, GlowProcess* process);
  55. /// Destruct.
  56. virtual ~GlowProcessResultHandler();
  57. void HandleResult(unsigned cmdID, const VariantMap& cmdResult);
  58. private:
  59. WeakPtr<GlowProcess> process_;
  60. };
  61. }