A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
EventLogService.h
Go to the documentation of this file.
1// Copyright(c) Pixo Group. All Rights Reserved.
2
3#pragma once
4
5#include "Events/BaseEvent.h"
6
8{
9 friend class EventLogService;
10
12 {
13 }
14
15public:
20 void operator=(const EventContainer&) = delete;
21
22 bool GetAll(TArray<UBaseEvent*>& OutEvents);
23 FORCEINLINE int32 Size() { return GetBuffer().Num(); };
24
25 FORCEINLINE bool Add(UBaseEvent* NewEvent)
26 {
27 if (NewEvent && NewEvent->Lock())
28 {
29 GetBuffer().Add(NewEvent);
30 return true;
31 }
32 return false;
33 }
34
35private:
36 FORCEINLINE TArray<UBaseEvent*>& GetBuffer()
37 {
39 }
40
41 void Swap();
42
43private:
44 TArray<UBaseEvent*> FirstBuffer;
45 TArray<UBaseEvent*> SecondBuffer;
46
47 bool FirstBufferInUse = true;
48};
49
55class PIXOCORE_API EventLogService
56{
57 friend class UExperienceManager;
58
60 {
61 };
62
63public:
68 void operator=(const EventLogService&) = delete;
69
76 template <typename TEventType>
77 FUNCTION_NON_NULL_RETURN_START
78 static TEventType* NewEvent(APlayerController* Executor = nullptr)
79 FUNCTION_NON_NULL_RETURN_END
80 {
81 static_assert(std::is_base_of<UBaseEvent, TEventType>::value, "TEventType should derive from UBaseEvent");
82
83 TEventType* Event = NewObject<TEventType>();
84 if (Events().Add(Event))
85 {
86 Event->Initialize(Executor);
87 }
88 return Event;
89 }
90
99 template <typename TEventType>
100 FUNCTION_NON_NULL_RETURN_START
101 static TEventType* NewEvent(UObject* Outer, UClass* TargetEventClass, APlayerController* Executor = nullptr)
102 FUNCTION_NON_NULL_RETURN_END
103 {
104 static_assert(std::is_base_of<UBaseEvent, TEventType>::value, "TEventType should derive from UBaseEvent");
105
106 TEventType* Event = NewObject<TEventType>(Outer, TargetEventClass);
107 if (Events().Add(Event))
108 {
109 Event->Initialize(Executor);
110 }
111 return Event;
112 }
113
124 template <typename TEventType, typename... TInitializeArgs>
125 FUNCTION_NON_NULL_RETURN_START
126 static TEventType* NewEvent(UObject* Outer, UClass* TargetEventClass, APlayerController* Executor, TInitializeArgs... Arguments)
127 FUNCTION_NON_NULL_RETURN_END
128 {
129 static_assert(std::is_base_of<UBaseEvent, TEventType>::value, "TEventType should derive from UBaseEvent");
130
131 TEventType* Event = NewObject<TEventType>(Outer, TargetEventClass);
132 if (Events().Add(Event))
133 {
134 Event->Initialize(Executor, Arguments...);
135 }
136 return Event;
137 }
138
148 template <typename TEventType, typename... TInitializeArgs>
149 FUNCTION_NON_NULL_RETURN_START
150 static TEventType* NewEvent(UObject* Outer, UClass* TargetEventClass, TInitializeArgs... Arguments)
151 FUNCTION_NON_NULL_RETURN_END
152 {
153 static_assert(std::is_base_of<UBaseEvent, TEventType>::value, "TEventType should derive from UBaseEvent");
154
155 TEventType* Event = NewObject<TEventType>(Outer, TargetEventClass);
156 if (Events().Add(Event))
157 {
158 Event->Initialize(nullptr, Arguments...);
159 }
160 return Event;
161 }
162
171 template <typename TEventType, typename... TInitializeArgs>
172 FUNCTION_NON_NULL_RETURN_START
173 static TEventType* NewEvent(APlayerController* Executor, TInitializeArgs... Arguments)
174 FUNCTION_NON_NULL_RETURN_END
175 {
176 static_assert(std::is_base_of<UBaseEvent, TEventType>::value, "TEventType should derive from UBaseEvent");
177
178 TEventType* Event = NewObject<TEventType>();
179 if (Events().Add(Event))
180 {
181 Event->Initialize(Executor, Arguments...);
182 }
183 return Event;
184 }
185
186private:
187 static EventContainer& Events();
188};
EventContainer(EventContainer &Other)=delete
TArray< UBaseEvent * > SecondBuffer
bool GetAll(TArray< UBaseEvent * > &OutEvents)
void operator=(const EventContainer &)=delete
FORCEINLINE bool Add(UBaseEvent *NewEvent)
FORCEINLINE TArray< UBaseEvent * > & GetBuffer()
FORCEINLINE int32 Size()
TArray< UBaseEvent * > FirstBuffer
provides functionality for creating and managing events. It is a friend class of UExperienceManager a...
EventLogService(EventLogService &Other)=delete
static FUNCTION_NON_NULL_RETURN_START TEventType * NewEvent(UObject *Outer, UClass *TargetEventClass, APlayerController *Executor=nullptr) FUNCTION_NON_NULL_RETURN_END
Creates a new event of the specified type with a specified outer object, target event class and optio...
static FUNCTION_NON_NULL_RETURN_START TEventType * NewEvent(APlayerController *Executor, TInitializeArgs... Arguments) FUNCTION_NON_NULL_RETURN_END
Creates a new event of the specified type.
static FUNCTION_NON_NULL_RETURN_START TEventType * NewEvent(UObject *Outer, UClass *TargetEventClass, APlayerController *Executor, TInitializeArgs... Arguments) FUNCTION_NON_NULL_RETURN_END
Creates a new event of the specified type with a specified outer object, target event class,...
void operator=(const EventLogService &)=delete
static FUNCTION_NON_NULL_RETURN_START TEventType * NewEvent(UObject *Outer, UClass *TargetEventClass, TInitializeArgs... Arguments) FUNCTION_NON_NULL_RETURN_END
Creates a new event of the specified type with a specified outer object and target event class.
static FUNCTION_NON_NULL_RETURN_START TEventType * NewEvent(APlayerController *Executor=nullptr) FUNCTION_NON_NULL_RETURN_END
Creates a new event of the specified type.
The UBaseEvent class serves as the base class for all events for our event-managers system....
Definition BaseEvent.h:83
virtual bool Lock() final
Definition BaseEvent.cpp:20
The UExperienceManager serves as the manager for handling the overall game experience....