Class UZagalaSpecDefaultRegexRegistry#

Inheritance Relationships#

Base Types#

Derived Type#

Class Documentation#

class UZagalaSpecDefaultRegexRegistry : public UObject, public IZagalaSpecRegexRegistry#

Abstract base implementation of IZagalaSpecRegexRegistry.

Stores a map from regex pattern strings to the soft paths of registered IZagalaSpecRegexIdentity entries, so registering and matching never load an asset. Blueprint entries are persisted in UZagalaSpecFeatureSettings on save and seed the registry singleton when it is created; native entries register in memory at class load. The first entry registered for a pattern wins; later entries for the same pattern are skipped with a warning. On class-load (CDO construction), derived registries register themselves with UZagalaSpecFeatureSettings so the editor can display them.

All singleton access and static dispatch are provided via templated static methods. Pass a derived registry type (e.g. UZagalaSpecStepRegistry) as the template argument — use Get<T>(), RegisterStatic<T>(), FindMatchingStatic<T>(), etc.

Subclassed by UZagalaSpecStepRegistry

Per-instance interface implementation

virtual bool Register(UObject *RegexIdentityObject) override#

Registers a UObject implementing IZagalaSpecRegexIdentity.

The pattern returned by GetRegexPattern() is stored as the key and the object’s soft path as the value. In the editor, the class default object of a Blueprint class is also persisted in UZagalaSpecFeatureSettings.

Parameters:

RegexIdentityObject – Must implement IZagalaSpecRegexIdentity; ignored if null or non-conforming.

Returns:

true if the pattern is mapped to the object after the call, false otherwise.

virtual bool RegisterRecord(const FString &Pattern, const FSoftObjectPath &Entry) override#

Registers a pattern for an entry by soft path, without loading the entry or persisting it.

Parameters:
  • Pattern – The regex pattern; ignored when empty.

  • Entry – The soft path of the owning entry; ignored when null.

Returns:

true if the pattern is mapped to Entry after the call. A pattern owned by another entry is kept and false is returned.

virtual FZagalaSpecRegexMatch FindMatch(const FString &RegexString) override#

Finds the first registered pattern that matches the given text.

Parameters:

RegexString – Plain text to test against stored patterns.

Returns:

The matched pattern and entry path, or an invalid match if no pattern matches.

virtual bool Unregister(const FString &Pattern) override#

Removes the entry keyed by the given regex pattern, including its persisted record in the editor.

Parameters:

Pattern – The exact regex pattern string used during registration.

Returns:

true if the pattern was found and removed, false if it was not registered.

virtual int32 UnregisterBatch(const TArray<FString> &Patterns) override#

Forwards each element of Patterns to Unregister(); returns the count of patterns actually removed.

virtual int32 UnregisterEntry(const FSoftObjectPath &Entry) override#

Removes every pattern owned by the entry, including its persisted records in the editor.

Parameters:

Entry – The soft path of the entry to remove.

Returns:

The number of patterns removed from this registry.

virtual void Clear() override#

Removes all registered entries from memory.

Persisted records are kept.

virtual const TMap<FString, FSoftObjectPath> &GetRegisteredEntries() const override#

Returns a read-only view of all registered pattern-to-entry mappings.

int32 GetRegisteredCount() const#

Returns the number of registered patterns.

Returns:

The count of registered entries.

void SeedFromSettings()#

Registers every persisted record of this registry class that is stored in UZagalaSpecFeatureSettings.

Called when the singleton is created.

static UZagalaSpecDefaultRegexRegistry *GetSingleton(UClass *RegistryClass)#

Returns the singleton instance for the given registry class.

Equivalent to Get<T>() but usable without a compile-time type.

Parameters:

RegistryClass – The registry class whose singleton is requested.

Returns:

The singleton registry instance.

Templated static dispatch (T must be a concrete derived registry type)

template<typename T>
static inline T &Get()#

Gets or lazily creates the singleton instance of registry type T.

Returns:

The singleton instance of T.

template<typename T>
static inline bool RegisterStatic(UObject *Object)#

Registers an object into registry T.

Parameters:

Object – Object implementing IZagalaSpecRegexIdentity.

Returns:

true if the object’s pattern is mapped to it after the call.

template<typename T>
static inline bool RegisterRecordStatic(const FString &Pattern, const FSoftObjectPath &Entry)#

Registers a pattern for an entry soft path into registry T without loading the entry.

Parameters:
  • Pattern – The regex pattern.

  • Entry – The soft path of the owning entry.

Returns:

true if the pattern is mapped to Entry after the call.

template<typename T>
static inline bool UnregisterStatic(const FString &Pattern)#

Removes the entry for the given pattern from registry T.

Parameters:

Pattern – The exact regex pattern used during registration.

Returns:

true if found and removed.

template<typename T>
static inline int32 UnregisterBatchStatic(const TArray<FString> &Patterns)#

Forwards each element of Patterns to Unregister() on registry T.

Parameters:

Patterns – The regex patterns to remove.

Returns:

The count of patterns actually removed.

template<typename T>
static inline FZagalaSpecRegexMatch FindMatchingStatic(const FString &Text)#

Finds the first match in registry T.

Parameters:

Text – Plain text to test against stored patterns.

Returns:

The matched pattern and entry path, or an invalid match if nothing matches.

template<typename T>
static inline int32 UnregisterEntryStatic(const FSoftObjectPath &Entry)#

Removes every pattern owned by the entry from registry T.

Parameters:

Entry – The soft path of the entry to remove.

Returns:

The number of patterns removed.

template<typename T>
static inline int32 GetRegisteredCountStatic()#

Returns the number of registered entries in registry T.

Returns:

The count of registered entries.

template<typename T>
static inline void ClearStatic()#

Clears all entries from registry T.

Public Functions

UZagalaSpecDefaultRegexRegistry(const FObjectInitializer &ObjectInitializer = FObjectInitializer::Get())#
virtual void PostInitProperties() override#

Public Static Functions

static void ReleaseSingletons()#

Unroots and forgets every registry singleton.

Called when the ZagalaSpec module shuts down.

Protected Attributes

TMap<FString, FSoftObjectPath> RegisteredEntries#

Map from regex pattern string to the soft path of the registered IZagalaSpecRegexIdentity entry.