Files
native_invoker_v2/src/detail/fxn.hpp

40 lines
1.1 KiB
C++

#pragma once
#include <functional>
#include <cstdint>
#include <fxn/context.hpp>
namespace fxn
{
using NativeHandler = void(*)(fxn::NativeContext*);
using NativeHash = std::uint64_t;
using NativeHook = std::function<bool(fxn::NativeContext*, bool& callOriginal)>;
class FxnManager
{
private:
struct Impl;
Impl* m_Impl;
FxnManager();
~FxnManager();
public:
static FxnManager& GetInstance();
static void Destroy();
static void DispatchNative(fxn::NativeContext* context, NativeHash hash);
public:
const NativeHandler& GetNativeHandler(const NativeHash hash) const;
void RegisterNativeHandler(const NativeHash hash, const NativeHandler handler);
public:
void RegisterNativeHook(const NativeHash hash, const NativeHook& hook);
void UnregisterNativeHook(const NativeHash hash);
public:
bool Invoke(fxn::NativeContext* context);
bool Schedule(fxn::NativeContext* context, bool waitForCompletion = true);
};
}