2323#include " ../Commands/JoinSecurityCommand.h"
2424#include " ../Commands/LeaveSecurityCommand.h"
2525#include " ../Shared/FactoryT.h"
26+ #include " ../Logging/loguru.hpp"
2627#include < Poco/Delegate.h>
2728#include < assert.h>
2829
@@ -107,13 +108,15 @@ EventDispatcher::~EventDispatcher()
107108// Helper(s)
108109void EventDispatcher::Enqueue (Message* pMessage)
109110{
111+ LOG_SCOPE_FUNCTION (8 );
110112 m_anEventQueueMutex.lock ();
111113 m_anEventQueue.push (pMessage);
112114 m_anEventQueueMutex.unlock ();
113115}
114116
115117Message* EventDispatcher::Dequeue ()
116118{
119+ LOG_SCOPE_FUNCTION (8 );
117120 Message* pMessage = NULL ;
118121
119122 m_anEventQueueMutex.lock ();
@@ -126,6 +129,8 @@ Message* EventDispatcher::Dequeue()
126129
127130GameEventBuffer* EventDispatcher::CreateGameEvent (EntityGameEventBuffer_EntityGameEventBufferType eEntityGameEvent_EntityGameEventBufferType, AEntity* pEntity)
128131{
132+ LOG_SCOPE_FUNCTION (8 );
133+ LOG_F (8 , " Entity Game Event" );
129134 EntityGameEvent_Dependencies anEntityGameEvent_Dependencies (eEntityGameEvent_EntityGameEventBufferType, pEntity);
130135 GameEventBuffer* pGameEvent = m_anEntityGameEventFactory.Create (anEntityGameEvent_Dependencies);
131136
@@ -134,6 +139,8 @@ GameEventBuffer* EventDispatcher::CreateGameEvent(EntityGameEventBuffer_EntityGa
134139
135140GameEventBuffer* EventDispatcher::CreateGameEvent (SecurityGameEventBuffer_SecurityGameEventBufferType eSecurityGameEvent_SecurityGameEventBufferType, const std::string& strUUID)
136141{
142+ LOG_SCOPE_FUNCTION (8 );
143+ LOG_F (8 , " Security Game Event" );
137144 SecurityGameEvent_Dependencies aSecurityGameEvent_Dependencies (eSecurityGameEvent_SecurityGameEventBufferType, strUUID);
138145 GameEventBuffer* pGameEvent = m_aSecurityGameEventFactory.Create (aSecurityGameEvent_Dependencies);
139146
@@ -143,6 +150,7 @@ GameEventBuffer* EventDispatcher::CreateGameEvent(SecurityGameEventBuffer_Securi
143150// Dispatches all the events it has received to it's listeners
144151void EventDispatcher::Dispatch ()
145152{
153+ LOG_SCOPE_FUNCTION (8 );
146154 Message* pMessage = NULL ;
147155 m_anEventQueueMutex.lock ();
148156 while (!m_anEventQueue.empty ())
@@ -157,75 +165,87 @@ void EventDispatcher::Dispatch()
157165// Entity event response
158166void EventDispatcher::HandlePodCreatedEvent (const void * pSender, Pod*& pPod)
159167{
168+ LOG_SCOPE_FUNCTION (8 );
160169 GameEventBuffer* pGameEvent = CreateGameEvent (EntityGameEventBuffer_EntityGameEventBufferType_CREATE, static_cast <AEntity*>(pPod));
161170 Enqueue (pGameEvent);
162171}
163172
164173void EventDispatcher::HandlePodUpdatedEvent (const void * pSender, Pod*& pPod)
165174{
175+ LOG_SCOPE_FUNCTION (8 );
166176 GameEventBuffer* pGameEvent = CreateGameEvent (EntityGameEventBuffer_EntityGameEventBufferType_UPDATE, static_cast <AEntity*>(pPod));
167177 Enqueue (pGameEvent);}
168178
169179void EventDispatcher::HandlePodDestroyedEvent (const void * pSender, Pod*& pPod)
170180{
181+ LOG_SCOPE_FUNCTION (8 );
171182 GameEventBuffer* pGameEvent = CreateGameEvent (EntityGameEventBuffer_EntityGameEventBufferType_DESTROY, static_cast <AEntity*>(pPod));
172183 Enqueue (pGameEvent);}
173184
174185void EventDispatcher::HandleBulletCreatedEvent (const void * pSender, Bullet*& pBullet)
175186{
187+ LOG_SCOPE_FUNCTION (8 );
176188 GameEventBuffer* pGameEvent = CreateGameEvent (EntityGameEventBuffer_EntityGameEventBufferType_CREATE, static_cast <AEntity*>(pBullet));
177189 Enqueue (pGameEvent);
178190}
179191
180192void EventDispatcher::HandleBulletUpdatedEvent (const void * pSender, Bullet*& pBullet)
181193{
194+ LOG_SCOPE_FUNCTION (8 );
182195 GameEventBuffer* pGameEvent = CreateGameEvent (EntityGameEventBuffer_EntityGameEventBufferType_UPDATE, static_cast <AEntity*>(pBullet));
183196 Enqueue (pGameEvent);
184197}
185198
186199void EventDispatcher::HandleBulletDestroyedEvent (const void * pSender, Bullet*& pBullet)
187200{
201+ LOG_SCOPE_FUNCTION (8 );
188202 GameEventBuffer* pGameEvent = CreateGameEvent (EntityGameEventBuffer_EntityGameEventBufferType_DESTROY, static_cast <AEntity*>(pBullet));
189203 Enqueue (pGameEvent);
190204}
191205
192206// Event Consumer event response
193207void EventDispatcher::HandleJoinSecurityCommandFactoryCreatedEvent (const void * pSender, JoinSecurityCommand*& pJoinSecurityCommand)
194208{
209+ LOG_SCOPE_FUNCTION (8 );
195210 assert (pJoinSecurityCommand);
196211
197212 pJoinSecurityCommand->ExecutedEvent += Poco::Delegate<EventDispatcher, const std::string&>(this , &EventDispatcher::HandleJoinSecurityCommandExecutedEvent);
198213}
199214
200215void EventDispatcher::HandleJoinSecurityCommandFactoryDestroyedEvent (const void * pSender, JoinSecurityCommand*& pJoinSecurityCommand)
201216{
217+ LOG_SCOPE_FUNCTION (8 );
202218 assert (pJoinSecurityCommand);
203219
204220 pJoinSecurityCommand->ExecutedEvent -= Poco::Delegate<EventDispatcher, const std::string&>(this , &EventDispatcher::HandleJoinSecurityCommandExecutedEvent);
205221}
206222
207223void EventDispatcher::HandleLeaveSecurityCommandFactoryCreatedEvent (const void * pSender, LeaveSecurityCommand*& pLeaveSecurityCommand)
208224{
225+ LOG_SCOPE_FUNCTION (8 );
209226 assert (pLeaveSecurityCommand);
210227
211228 pLeaveSecurityCommand->ExecutedEvent += Poco::Delegate<EventDispatcher, const std::string&>(this , &EventDispatcher::HandleLeaveSecurityCommandExecutedEvent);
212229}
213230
214231void EventDispatcher::HandleLeaveSecurityCommandFactoryDestroyedEvent (const void * pSender, LeaveSecurityCommand*& pLeaveSecurityCommand)
215232{
233+ LOG_SCOPE_FUNCTION (8 );
216234 assert (pLeaveSecurityCommand);
217235
218236 pLeaveSecurityCommand->ExecutedEvent -= Poco::Delegate<EventDispatcher, const std::string&>(this , &EventDispatcher::HandleLeaveSecurityCommandExecutedEvent);
219237}
220238
221239void EventDispatcher::HandleJoinSecurityCommandExecutedEvent (const void * pSender, const std::string& strUUID)
222240{
241+ LOG_SCOPE_FUNCTION (8 );
223242 GameEventBuffer* pGameEvent = CreateGameEvent (SecurityGameEventBuffer_SecurityGameEventBufferType_JOIN, strUUID);
224243 Enqueue (pGameEvent);
225244}
226245
227246void EventDispatcher::HandleLeaveSecurityCommandExecutedEvent (const void * pSender, const std::string& strUUID)
228247{
248+ LOG_SCOPE_FUNCTION (8 );
229249 GameEventBuffer* pGameEvent = CreateGameEvent (SecurityGameEventBuffer_SecurityGameEventBufferType_LEAVE, strUUID);
230250 Enqueue (pGameEvent);
231251}
0 commit comments