VisualScriptClassRegistry
- Module
- VisualScripting
- Header
#include "VisualScripting/VisualScriptClassRegistry.h"- Namespace
Mowo
Type aliases
| Alias | Description |
|---|---|
using ActorFactory = MObject* (*)() | The gameplay layer's backing-actor factory (returns new AVisualScriptActor() typed as MObject*). Every synthetic class uses it as its MClass.construct. nativeBaseClass names the class the factory actually constructs: a synthetic declaring a native parent OUTSIDE that class's ancestry would make IsChildOf lie about an object that is not that type, and every static_cast through the claim corrupts — registration checks against it. |
Properties
| Type | Name | Description |
|---|---|---|
static constexpr uint32_t | kNativeHostSlots | MClass::construct is a plain function pointer, so each hosted class owns one numbered trampoline that finds its synthetic class again. Default 512. |
Constructors
| Signature | Name | Description |
|---|---|---|
VisualScriptClassRegistry(const VisualScriptClassRegistry&) = delete | VisualScriptClassRegistry |
Public functions
| Returns | Name | Description |
|---|---|---|
VisualScriptClassRegistry& | Get | |
VisualScriptClassRegistry& | operator= | |
void | SetActorFactory | |
bool | HasActorFactory | |
void | AddBackingClass | A backing class for Visual Script classes whose native parent is nativeParent or derives from it: AVisualScriptCharacter for ACharacter, AVisualScriptPawn for APawn. |
FName | BackingClassOf | The backing class a registered Visual Script class spawns as. |
void | SetNativeHost | |
bool | UsesNativeHost | True when def (parents already resolved) would be hosted on its native parent rather than a backing class. |
MClass* | NativeParentOf | The native MClass the root of def's Visual Script chain declares as its parent, or null when it names none that resolves. |
MObject* | ConstructHosted | Game thread only; the registry lock is held across construction. |
MClass* | Register | Take ownership of def, synthesize its MClass, and register it by name. |
std::vector<std::unique_ptr<VisualScriptClass>> | OrderParentsFirst | Orders parsed classes so every Visual Script parent precedes its children. |
std::vector<std::unique_ptr<VisualScriptClass>> | LoadClassFiles | Parses every file once, on up to eight workers, and returns the classes that loaded with a name, in paths order (what OrderParentsFirst takes). |
MClass* | Reregister | Hot-reload: swap the definition behind an already-registered name. |
bool | Unregister | Drop a registered class (removes it from MClassRegistry and frees its storage). |
VisualScriptClass* | Find | The VisualScriptClass behind a registered name, or nullptr. |
std::vector<VisualScriptClass*> | CollectClasses | Every registered definition, in registration order. |
uint32_t | Revision | Bumped on every Register / Reregister / Unregister / Clear — lets a cache notice new classes without walking the table each frame. |
void | Clear | Drop everything (tests / shutdown). |
size_t | Num | |
void | AddPending | Lazy registration. |
MClass* | ResolvePending | |
uint32_t | ResolveAllPending | |
size_t | PendingCount | |
uint32_t | PendingParses | How many definitions the pending path parsed from disk, ever. |
Function details
VisualScriptClassRegistry
VisualScriptClassRegistry(const VisualScriptClassRegistry&) = deleteGet
static VisualScriptClassRegistry& Get()operator=
VisualScriptClassRegistry& operator=(const VisualScriptClassRegistry&) = deleteSetActorFactory
void SetActorFactory(ActorFactory factory, FName nativeBaseClass = FName())HasActorFactory
bool HasActorFactory() constAddBackingClass
void AddBackingClass(FName nativeParent, ActorFactory factory, FName backingClass)A backing class for Visual Script classes whose native parent is nativeParent or derives from it: AVisualScriptCharacter for ACharacter, AVisualScriptPawn for APawn. Registration picks the one nearest the declared parent up its native chain, and falls back to the SetActorFactory default; before this every Visual Script class was an AVisualScriptActor whatever it declared.
BackingClassOf
FName BackingClassOf(FName visualScriptClassName) constThe backing class a registered Visual Script class spawns as.
SetNativeHost
void SetNativeHost(const FNativeHost& host)UsesNativeHost
bool UsesNativeHost(const VisualScriptClass& def) constTrue when def (parents already resolved) would be hosted on its native parent rather than a backing class.
NativeParentOf
static MClass* NativeParentOf(const VisualScriptClass& def)The native MClass the root of def's Visual Script chain declares as its parent, or null when it names none that resolves.
ConstructHosted
MObject* ConstructHosted(uint32_t slot)Game thread only; the registry lock is held across construction.
Register
MClass* Register(std::unique_ptr<VisualScriptClass> def)Take ownership of def, synthesize its MClass, and register it by name. Returns the synthetic MClass* (also discoverable via MClassRegistry:: FindByName), or nullptr if no factory is installed or the name is taken.
OrderParentsFirst
static std::vector<std::unique_ptr<VisualScriptClass>> OrderParentsFirst(std::vector<std::unique_ptr<VisualScriptClass>> classes)Orders parsed classes so every Visual Script parent precedes its children. Register resolves a class's Visual Script parent once, at registration, and a parent it cannot find yet reads as native — a child registered first runs without the parent's variables and graphs for the whole session. Order is otherwise kept; classes in a parent cycle, or whose parent is not in the set and not registered, follow in their original order.
LoadClassFiles
static std::vector<std::unique_ptr<VisualScriptClass>> LoadClassFiles(const std::vector<std::string>& paths, std::vector<std::string>* outFailures = nullptr)Parses every file once, on up to eight workers, and returns the classes that loaded with a name, in paths order (what OrderParentsFirst takes). A parse touches no registry, so only the registration after it has to stay on the calling thread; the editor parsed every project class serially before its first frame. A file that fails is logged and named in outFailures.
Reregister
MClass* Reregister(std::unique_ptr<VisualScriptClass> def)Hot-reload: swap the definition behind an already-registered name. The synthetic MClass instance is REUSED (its pointer is what live actors and MClassRegistry hold) — only userData / super link change; children's parentVisualScript links re-point at the new definition. Falls back to Register when the name is new. Live actors rebind lazily on their next graph dispatch, keeping variable state.
Unregister
bool Unregister(FName className)Drop a registered class (removes it from MClassRegistry and frees its storage). Returns true if found.
Find
VisualScriptClass* Find(FName className) constThe VisualScriptClass behind a registered name, or nullptr.
CollectClasses
std::vector<VisualScriptClass*> CollectClasses() constEvery registered definition, in registration order. The debug tooling (DAP source listing, breakpoint resolution) enumerates through this.
Revision
uint32_t Revision() constBumped on every Register / Reregister / Unregister / Clear — lets a cache notice new classes without walking the table each frame.
Clear
void Clear()Drop everything (tests / shutdown). Unregisters each name first.
Num
size_t Num() constAddPending
void AddPending(const std::string& className, const std::string& parentClassName, const std::string& path, std::unique_ptr<VisualScriptClass> parsed = nullptr)Lazy registration. A class known by name and file (FVisualScriptClassIndex) but not registered: the first FindByName for it — a scene placing one, a spawn by class — parses (unless parsed already holds the definition) and registers it, parents first; anything enumerating classes (MClassRegistry::GetAllClasses, CollectClasses) registers every pending one first. Registering a name directly drops its pending entry. The first call installs the MClassRegistry hooks.
ResolvePending
MClass* ResolvePending(FName className)ResolveAllPending
uint32_t ResolveAllPending()PendingCount
size_t PendingCount() constPendingParses
uint32_t PendingParses() constHow many definitions the pending path parsed from disk, ever.