UnrealModFramework
Mod framework API
Loading...
Searching...
No Matches
ModAPIHost.h
Go to the documentation of this file.
1// Copyright (c) 2026 Nelaric Contributors
3#pragma once
4
5#include "ModAPIRegistry.h"
6#include "UObject/StrongObjectPtr.h"
7
8struct FModExtensionWorld;
9
10namespace Mod::API
11{
13class MODAPI_API FServiceInvocation
14{
15public:
17 FServiceInvocation() = default;
20
21private:
23 FServiceInvocation& operator=(const FServiceInvocation&) = delete;
24 friend struct FHostAccess;
25 TSharedPtr<FModExtensionWorld> World;
26 TStrongObjectPtr<UObject> Target;
27};
28
31{
32public:
35
41 explicit FGeneratedHostRegistration(FRegister InRegister, const TCHAR* InModule = nullptr,
42 const TCHAR* InExportHash = nullptr);
44 static void DescribeContracts(TArray<FString>& Digests);
47
48private:
51
52 friend class ::UModAPIHostSubsystem;
53 friend class FModAPIModule;
54 static TModResult<TArray<FRegistration>> RegisterAll(FRegistry& Registry);
55
56 static FGeneratedHostRegistration* First;
58 FRegister Register;
59 const TCHAR* Module;
60 const TCHAR* ExportHash;
61 TArray<TWeakPtr<FRegistrationState>> ActiveTypes;
62};
63
65struct MODAPI_API FHostAccess
66{
76 static TModResult<UObject*> Enter(const FObjectBinding& Binding, FName TypeId, EScope Scope,
77 TConstArrayView<FName> Permissions, bool bMutable,
78 FServiceInvocation* Invocation = nullptr);
84 static TModResult<void> ValidateObjectInput(const FObjectBinding& Binding, const UObject* Object);
92 static TModResult<UObject*> ResolveObjectInput(const FObjectBinding& Binding, UClass* Class, const ANSICHAR* Path,
93 uint32 Size);
102 static TModResult<FObjectBinding> ProjectObject(const FObjectBinding& Source, UObject* Object, FName TypeId,
103 const TCHAR* Signature, bool bReadOnly);
104
112 UObject& Target, int32 Index);
113};
114} // namespace Mod::API
EScope
Supported scope kinds for the synchronous UObject backend.
Definition ModAPIRegistry.h:23
static void DescribeContracts(TArray< FString > &Digests)
Collects the distinct export digests registered by this host.
void(*)(FRegistry &, TModResult< TArray< FRegistration > > &) FRegister
Signature of a generated registration entry point.
Definition ModAPIHost.h:34
~FGeneratedHostRegistration()
Withdraws the entry point and invalidates its live type registrations.
FGeneratedHostRegistration(FRegister InRegister, const TCHAR *InModule=nullptr, const TCHAR *InExportHash=nullptr)
Publishes an entry point for future game instances.
An opaque, non-owning object binding with a cached typed calling table.
Definition ModAPIObject.h:18
Owns a session's generated definitions, providers, scopes, and callers.
Definition ModAPIRegistry.h:117
Keeps the World and target alive for one generated service call.
Definition ModAPIHost.h:14
~FServiceInvocation()
Releases the call at the World dispatch boundary.
FServiceInvocation()=default
Starts without owning a service call.
A synchronous API result containing either a value or a stable error.
Definition ModAPIResult.h:47
Host-only operations used by concrete generated calling bridges.
Definition ModAPIHost.h:66
static TModResult< TSharedPtr< const FBlueprintCall > > ResolveBlueprintCall(const FObjectBinding &Binding, UObject &Target, int32 Index)
Gets a validated Blueprint call on the game thread.
static TModResult< FObjectBinding > ProjectObject(const FObjectBinding &Source, UObject *Object, FName TypeId, const TCHAR *Signature, bool bReadOnly)
Projects a returned object into an authorized non-owning binding.
static TModResult< void > ValidateObjectInput(const FObjectBinding &Binding, const UObject *Object)
Checks a borrowed UE object argument on the game thread.
static TModResult< UObject * > ResolveObjectInput(const FObjectBinding &Binding, UClass *Class, const ANSICHAR *Path, uint32 Size)
Resolves an already loaded argument by its exact object path.
static TModResult< UObject * > Enter(const FObjectBinding &Binding, FName TypeId, EScope Scope, TConstArrayView< FName > Permissions, bool bMutable, FServiceInvocation *Invocation=nullptr)
Enters a synchronous generated call on the game thread.