Plasma Engine  2.0
Loading...
Searching...
No Matches
EngineProcessConnection.h
1#pragma once
2
3#include <EditorEngineProcessFramework/EngineProcess/EngineProcessMessages.h>
4#include <EditorFramework/EditorFrameworkDLL.h>
5#include <EditorFramework/IPC/EditorProcessCommunicationChannel.h>
6#include <Foundation/Application/Config/PluginConfig.h>
7#include <Foundation/Communication/Event.h>
8#include <Foundation/Configuration/Singleton.h>
9#include <Foundation/Types/UniquePtr.h>
10#include <GuiFoundation/UIServices/UIServices.moc.h>
11
13class plDocument;
18class plAssetDocument;
19
20class PL_EDITORFRAMEWORK_DLL plEditorEngineProcessConnection
21{
22 PL_DECLARE_SINGLETON(plEditorEngineProcessConnection);
23
24public:
27
30 void SetFileSystemConfig(const plApplicationFileSystemConfig& cfg) { m_FileSystemConfig = cfg; }
31
34 void SetPluginConfig(const plApplicationPluginConfig& cfg) { m_PluginConfig = cfg; }
35
36 void Update();
37 plResult RestartProcess();
38 void ShutdownProcess();
39 bool IsProcessCrashed() const { return m_bProcessCrashed; }
40
41 plEditorEngineConnection* CreateEngineConnection(plAssetDocument* pDocument);
42 void DestroyEngineConnection(plAssetDocument* pDocument);
43
44 bool SendMessage(plProcessMessage* pMessage);
45
49 plResult WaitForMessage(const plRTTI* pMessageType, plTime timeout, plProcessCommunicationChannel ::WaitForMessageCallback* pCallback = nullptr);
53 plResult WaitForDocumentMessage(
54 const plUuid& assetGuid, const plRTTI* pMessageType, plTime timeout, plProcessCommunicationChannel::WaitForMessageCallback* pCallback = nullptr);
55
56 bool IsEngineSetup() const { return m_bClientIsConfigured; }
57
58 void ActivateRemoteProcess(const plAssetDocument* pDocument, plUInt32 uiViewID);
59
60 plProcessCommunicationChannel& GetCommunicationChannel() { return m_IPC; }
61
62 struct Event
63 {
64 enum class Type
65 {
66 Invalid,
67 ProcessStarted,
68 ProcessCrashed,
69 ProcessShutdown,
70 ProcessMessage,
71 ProcessRestarted,
72 };
73
74 Event()
75 {
76 m_Type = Type::Invalid;
77 m_pMsg = nullptr;
78 }
79
80 Type m_Type;
81 const plProcessMessage* m_pMsg;
82 };
83
84 static plEvent<const Event&> s_Events;
85
86private:
87 void Initialize(const plRTTI* pFirstAllowedMessageType);
88 void HandleIPCEvent(const plProcessCommunicationChannel::Event& e);
89 void UIServicesTickEventHandler(const plQtUiServices::TickEvent& e);
90 bool ConnectToRemoteProcess();
91 void ShutdownRemoteProcess();
92
93 bool m_bProcessShouldBeRunning;
94 bool m_bProcessCrashed;
95 bool m_bClientIsConfigured;
96 plEventSubscriptionID m_TickEventSubscriptionID = 0;
97 plUInt32 m_uiRedrawCountSent = 0;
98 plUInt32 m_uiRedrawCountReceived = 0;
99
102 plApplicationFileSystemConfig m_FileSystemConfig;
103 plApplicationPluginConfig m_PluginConfig;
105};
106
107class PL_EDITORFRAMEWORK_DLL plEditorEngineConnection
108{
109public:
110 bool SendMessage(plEditorEngineDocumentMsg* pMessage);
111 void SendHighlightObjectMessage(plViewHighlightMsgToEngine* pMessage);
112
113 plDocument* GetDocument() const { return m_pDocument; }
114
115private:
117 plEditorEngineConnection(plDocument* pDocument) { m_pDocument = pDocument; }
118 ~plEditorEngineConnection() = default;
119
120 plDocument* m_pDocument;
121};
Definition FileSystemConfig.h:8
Definition PluginConfig.h:9
Definition AssetDocument.h:42
Definition Document.h:57
Definition DocumentObjectBase.h:11
Definition EngineProcessConnection.h:108
Base class for all messages that are tied to some document.
Definition EngineProcessMessages.h:151
Definition EngineProcessConnection.h:21
void SetPluginConfig(const plApplicationPluginConfig &cfg)
The given plugin configuration will be used by the engine process to load runtime plugins....
Definition EngineProcessConnection.h:34
void SetFileSystemConfig(const plApplicationFileSystemConfig &cfg)
The given file system configuration will be used by the engine process to setup the runtime data dire...
Definition EngineProcessConnection.h:30
Definition EditorProcessCommunicationChannel.h:13
Definition Event.h:177
Definition HashTable.h:333
Definition ProcessCommunicationChannel.h:14
Base class for IPC messages transmitted by plIpcChannel.
Definition RemoteMessage.h:64
Base class for all document windows that need a connection to the engine process, and might want to r...
Definition EngineDocumentWindow.moc.h:37
This class holds information about reflected types. Each instance represents one type that is known t...
Definition RTTI.h:30
A Unique ptr manages an object and destroys that object when it goes out of scope....
Definition UniquePtr.h:10
This data type is the abstraction for 128-bit Uuid (also known as GUID) instances.
Definition Uuid.h:11
Definition EngineProcessMessages.h:401
Used by plDocumentObjectManager::m_PropertyEvents.
Definition DocumentObjectManager.h:77
Used by plDocumentObjectManager::m_StructureEvents.
Definition DocumentObjectManager.h:45
Definition EngineProcessConnection.h:63
Definition ProcessCommunicationChannel.h:33
Definition UIServices.moc.h:49
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12