Rename to HookableEvent. Because naming conflict

This commit is contained in:
Scott Mansell 2023-02-03 13:37:42 +13:00
parent 60f2b5af7b
commit 8c8bd0e7ac
5 changed files with 12 additions and 12 deletions

View File

@ -46,7 +46,6 @@ add_library(common
EnumFormatter.h EnumFormatter.h
EnumMap.h EnumMap.h
Event.h Event.h
EventHook.h
FatFsUtil.cpp FatFsUtil.cpp
FatFsUtil.h FatFsUtil.h
FileSearch.cpp FileSearch.cpp
@ -63,6 +62,7 @@ add_library(common
GekkoDisassembler.h GekkoDisassembler.h
Hash.cpp Hash.cpp
Hash.h Hash.h
HookableEvent.h
HttpRequest.cpp HttpRequest.cpp
HttpRequest.h HttpRequest.h
Image.cpp Image.cpp

View File

@ -19,7 +19,7 @@ namespace Common
// Define Events in a header as: // Define Events in a header as:
// //
// using MyLoveyEvent = Event<"My lovely event", std::string>; // using MyLoveyEvent = HookableEvent<"My lovely event", std::string>;
// //
// Register listeners anywhere you need them as: // Register listeners anywhere you need them as:
// EventHook myHook = MyLoveyEvent::Register([](std::string foo) { // EventHook myHook = MyLoveyEvent::Register([](std::string foo) {
@ -40,7 +40,7 @@ struct HookBase
using EventHook = std::unique_ptr<HookBase>; using EventHook = std::unique_ptr<HookBase>;
template <StringLiteral EventName, typename... CallbackArgs> template <StringLiteral EventName, typename... CallbackArgs>
class Event class HookableEvent
{ {
public: public:
using CallbackType = std::function<void(CallbackArgs...)>; using CallbackType = std::function<void(CallbackArgs...)>;
@ -48,7 +48,7 @@ public:
private: private:
struct HookImpl final : public HookBase struct HookImpl final : public HookBase
{ {
~HookImpl() override { Event::Remove(this); } ~HookImpl() override { HookableEvent::Remove(this); }
HookImpl(CallbackType callback, std::string name) HookImpl(CallbackType callback, std::string name)
: m_fn(std::move(callback)), m_name(std::move(name)) : m_fn(std::move(callback)), m_name(std::move(name))
{ {

View File

@ -9,7 +9,7 @@
#include <vector> #include <vector>
#include "Common/Assert.h" #include "Common/Assert.h"
#include "Common/EventHook.h" #include "Common/HookableEvent.h"
#include "Core/FifoPlayer/FifoDataFile.h" #include "Core/FifoPlayer/FifoDataFile.h"
class FifoRecorder class FifoRecorder

View File

@ -46,7 +46,6 @@
<ClInclude Include="Common\EnumFormatter.h" /> <ClInclude Include="Common\EnumFormatter.h" />
<ClInclude Include="Common\EnumMap.h" /> <ClInclude Include="Common\EnumMap.h" />
<ClInclude Include="Common\Event.h" /> <ClInclude Include="Common\Event.h" />
<ClInclude Include="Common\EventHook.h" />
<ClInclude Include="Common\FatFsUtil.h" /> <ClInclude Include="Common\FatFsUtil.h" />
<ClInclude Include="Common\FileSearch.h" /> <ClInclude Include="Common\FileSearch.h" />
<ClInclude Include="Common\FileUtil.h" /> <ClInclude Include="Common\FileUtil.h" />
@ -110,6 +109,7 @@
<ClInclude Include="Common\GL\GLUtil.h" /> <ClInclude Include="Common\GL\GLUtil.h" />
<ClInclude Include="Common\GL\GLX11Window.h" /> <ClInclude Include="Common\GL\GLX11Window.h" />
<ClInclude Include="Common\Hash.h" /> <ClInclude Include="Common\Hash.h" />
<ClInclude Include="Common\HookableEvent.h" />
<ClInclude Include="Common\HRWrap.h" /> <ClInclude Include="Common\HRWrap.h" />
<ClInclude Include="Common\HttpRequest.h" /> <ClInclude Include="Common\HttpRequest.h" />
<ClInclude Include="Common\Image.h" /> <ClInclude Include="Common\Image.h" />

View File

@ -4,19 +4,19 @@
#pragma once #pragma once
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/EventHook.h" #include "Common/HookableEvent.h"
// Called when certain video config setting are changed // Called when certain video config setting are changed
using ConfigChangedEvent = Common::Event<"ConfigChanged", u32>; using ConfigChangedEvent = Common::HookableEvent<"ConfigChanged", u32>;
// An event called just before the first draw call of a frame // An event called just before the first draw call of a frame
using BeforeFrameEvent = Common::Event<"BeforeFrame">; using BeforeFrameEvent = Common::HookableEvent<"BeforeFrame">;
// An event called after the frame XFB copy begins processing on the host GPU. // An event called after the frame XFB copy begins processing on the host GPU.
// Useful for "once per frame" usecases. // Useful for "once per frame" usecases.
// Note: In a few rare cases, games do multiple XFB copies per frame and join them while presenting. // Note: In a few rare cases, games do multiple XFB copies per frame and join them while presenting.
// If this matters to your usecase, you should use BeforePresent instead. // If this matters to your usecase, you should use BeforePresent instead.
using AfterFrameEvent = Common::Event<"AfterFrame">; using AfterFrameEvent = Common::HookableEvent<"AfterFrame">;
struct PresentInfo struct PresentInfo
{ {
@ -76,8 +76,8 @@ struct PresentInfo
// frame. // frame.
// //
// frame_count: The number of frames // frame_count: The number of frames
using BeforePresentEvent = Common::Event<"BeforePresent", PresentInfo&>; using BeforePresentEvent = Common::HookableEvent<"BeforePresent", PresentInfo&>;
// An event that is triggered after a frame is presented. // An event that is triggered after a frame is presented.
// The exact timing of this event depends on backend/driver support. // The exact timing of this event depends on backend/driver support.
using AfterPresentEvent = Common::Event<"AfterPresent", PresentInfo&>; using AfterPresentEvent = Common::HookableEvent<"AfterPresent", PresentInfo&>;