|
Config Forge 1.0.0
|
Game instance subsystem for managing configuration files and categories in the ConfigForge plugin. More...
#include <ConfigForgeSubsystem.h>
Public Member Functions | |
| const UConfigForgeDeveloperSettings * | GetSettings () const |
| Gets the developer settings for the ConfigForge system. | |
| TSoftObjectPtr< UConfigForgeSetup > | GetSetupAsset () const |
| Retrieves the setup asset reference from developer settings. | |
| bool | GetFile (const FString &InFileName, FConfigForgeFileData &OutFileData) const |
| Retrieves a specific configuration file by name. | |
| void | GetFiles (TArray< FConfigForgeFileData > &OutFiles) const |
| Retrieves all valid configuration files from the setup asset. | |
| void | GetFileNames (TArray< FString > &OutNames) const |
| Retrieves the names of all configuration files in the setup asset. | |
| void | GetFileCategoriesByName (const FString &InFileName, TArray< FName > &OutCategories) |
| Retrieves all category names from a file specified by name. | |
| void | GetFileCategories (const FConfigForgeFileData &InFileData, TArray< FName > &OutCategories) |
| Retrieves all category names from a file data structure. | |
| void | GetCategoryProperties (const FString &InFileName, const FName &InCategoryName, TArray< UConfigValueObject * > &OutProperties) |
| Retrieves all property value objects from a specific category within a file. | |
| bool | GetRuntimeFile (const FGuid &InUniqueFileId, UConfigForgeFileRuntime *&OutRuntimeFile) const |
| Retrieves a loaded runtime file instance by its unique ID. | |
| void | GetAllRuntimeFiles (TArray< UConfigForgeFileRuntime * > &OutRuntimeFiles) const |
| Retrieves all runtime configuration files currently loaded in the subsystem. | |
| bool | GetRuntimeCategories (const UConfigForgeFileRuntime *InConfigFile, TArray< UConfigForgeCategoryRuntime * > &OutCategories) const |
| Retrieves all categories from a specific runtime configuration file. | |
| bool | GetRuntimeCategories_ID (const FGuid &InFileId, TArray< UConfigForgeCategoryRuntime * > &OutCategories) const |
| Retrieves all categories from a runtime configuration file identified by its GUID. | |
| bool | GetRuntimeCategory (const UConfigForgeFileRuntime *InConfigFile, const FName &InCategoryName, UConfigForgeCategoryRuntime *&OutCategory) const |
| Retrieves a specific category by name from a runtime configuration file. | |
| bool | GetRuntimeCategory_ID (const FGuid &InFileId, const FName &InCategoryName, UConfigForgeCategoryRuntime *&OutCategory) const |
| Retrieves a specific category by name from a runtime configuration file identified by its GUID. | |
| bool | GetRuntimeField (const UConfigForgeCategoryRuntime *InRuntimeCategory, const FString &InKey, UConfigValueObjectRuntime *&OutField) const |
| Retrieves a specific field by key from a runtime category. | |
| bool | GetRuntimeField_Full (const FGuid &InFiledId, const FName &InCategoryName, const FString &InFieldName, UConfigForgeFileRuntime *&OutFile, UConfigForgeCategoryRuntime *&OutCategory, UConfigValueObjectRuntime *&OutField) const |
| Retrieves a runtime field by providing its file ID, category name, and field name. | |
| bool | GetRuntimeField_File (const UConfigForgeFileRuntime *InConfigFile, const FName &InCategoryName, const FString &InKey, UConfigValueObjectRuntime *&OutField) const |
| Retrieves a specific field by key from a category within a runtime configuration file. | |
| bool | GetRuntimeField_ID (const FGuid &InFileID, const FName &InCategoryName, const FString &InKey, UConfigValueObjectRuntime *&OutField) const |
| Retrieves a specific field by key from a category within a runtime configuration file identified by its GUID. | |
| bool | GetRuntimeFields (const UConfigForgeCategoryRuntime *InRuntimeCategory, TArray< UConfigValueObjectRuntime * > &OutFields) const |
| Retrieves all fields from a runtime category. | |
| bool | GetRuntimeFields_File (const UConfigForgeFileRuntime *InConfigFile, const FName &InCategoryName, TArray< UConfigValueObjectRuntime * > &OutFields) const |
| Retrieves all fields from a category within a runtime configuration file. | |
| bool | GetRuntimeFields_ID (const FGuid &InFileID, const FName &InCategoryName, TArray< UConfigValueObjectRuntime * > &OutFields) const |
| Retrieves all fields from a category within a runtime configuration file identified by its GUID. | |
| FORCEINLINE bool | IsOperatingFiles () const |
| Checks whether a file load/save operation is currently in progress. | |
| bool | LoadSingleFile (const FConfigForgeFileData &InFileData, UConfigForgeFileRuntime *&OutFile) |
| Synchronously loads a single config file from disk. | |
| void | LoadSingleFileAsync (const FConfigForgeFileData &InFileData, FLoadForgeFileDelegate Callback) |
| Asynchronously loads a single config file from disk. | |
| bool | SaveSingleFile (const FGuid &InFileUniqueID) |
| Synchronously saves a single loaded config file to disk. | |
| void | SaveSingleFileAsync (const FGuid &InFileUniqueID, FSaveForgeFileDelegate Callback) |
| Asynchronously saves a single loaded config file to disk. | |
| bool | LoadAllFiles (TArray< UConfigForgeFileRuntime * > &OutFiles) |
| Loads all configuration files synchronously. | |
| void | LoadAllFilesAsync (FLoadAllForgeFileDelegate Callback) |
| Loads all configuration files asynchronously. | |
| bool | LoadSelectedFiles (const TArray< FConfigForgeFileData > &InFiles, TArray< UConfigForgeFileRuntime * > &OutFiles) |
| Synchronously loads a selected subset of config files into runtime objects. | |
| void | LoadSelectedFilesAsync (const TArray< FConfigForgeFileData > &InFiles, FLoadAllForgeFileDelegate Callback) |
| Asynchronously loads a selected subset of config files into runtime objects. | |
| bool | SaveAllFiles () |
| Saves all currently loaded runtime configuration files synchronously. | |
| void | SaveAllFilesAsync (FSaveAllForgeFileDelegate Callback) |
| Saves all currently loaded runtime configuration files asynchronously. | |
| bool | SaveSelectedFiles (const TArray< FGuid > &InFiles) |
| Synchronously saves the specified files to disk. | |
| void | SaveSelectedFiles (const TArray< FGuid > &InFiles, FSaveSelectedForgeFileDelegate Callback) |
| Asynchronously saves the specified files and calls delegate upon completion. | |
Static Public Member Functions | |
| static void | GetFilesStatic (UConfigForgeSetup *InSetupFile, TArray< FConfigForgeFileData > &OutFiles) |
Protected Member Functions | |
| bool | ReadFileInternal (TSubclassOf< UConfigPathProvider > InPathProviderClass, const FGuid &InId, UConfigForgeFile *InTemplate, UConfigForgeFileRuntime *&OutFile) |
| Internal function that loads (and creates) a config file from disk. | |
| bool | WriteFileInternal (UConfigForgeFileRuntime *InFile) |
| Internal function that writes a runtime file to disk. | |
| bool | LoadAllFilesInternal (const TArray< FConfigForgeFileData > &InDataArr, TArray< UConfigForgeFileRuntime * > &OutFiles) |
| Internal helper that loads multiple config files from structured data into runtime objects. | |
| bool | WriteAllFilesInternal (const TArray< UConfigForgeFileRuntime * > &InFiles) |
| Internal helper that writes multiple runtime config files to disk. | |
Protected Attributes | |
| TMap< FGuid, TObjectPtr< UConfigForgeFileRuntime > > | RuntimeFiles |
| FThreadSafeBool | bOperatingFiles |
Game instance subsystem for managing configuration files and categories in the ConfigForge plugin.
UConfigForgeSubsystem provides a centralized interface for accessing and querying configuration data organized in a hierarchical structure of Files -> Categories -> Properties. It serves as the main API entry point for the ConfigForge system within a game instance.
The subsystem manages access to:
The ConfigForge system uses a three-level hierarchy:
Before using this subsystem, you must configure the setup asset in: Project Settings -> Config Forge -> 'ConfigSetup'
The setup asset (UConfigForgeSetup) must contain at least one file with valid categories and properties for the subsystem to function properly.
This subsystem performs synchronous asset loading operations and should be called from the game thread only. All getter methods are const-correct but load assets synchronously, which may cause hitches if called frequently.
The subsystem uses the LogConfigForge logging category for all error and warning messages:
| void UConfigForgeSubsystem::GetAllRuntimeFiles | ( | TArray< UConfigForgeFileRuntime * > & | OutRuntimeFiles | ) | const |
Retrieves all runtime configuration files currently loaded in the subsystem.
| OutRuntimeFiles | [out] Array that will be populated with pointers to all runtime files. |
| void UConfigForgeSubsystem::GetCategoryProperties | ( | const FString & | InFileName, |
| const FName & | InCategoryName, | ||
| TArray< UConfigValueObject * > & | OutProperties ) |
Retrieves all property value objects from a specific category within a file.
Looks up a file by name, finds the specified category within that file, and returns all configuration property value objects (Fields) defined in that category.
| InFileName | The name of the file containing the category. |
| InCategoryName | The name of the category to retrieve properties from. |
| OutProperties | [out] Array to populate with property value objects. Will be emptied before population. |
| bool UConfigForgeSubsystem::GetFile | ( | const FString & | InFileName, |
| FConfigForgeFileData & | OutFileData ) const |
Retrieves a specific configuration file by name.
Searches through all files in the setup asset and returns the file data matching the specified file name. The search is case-sensitive and performs a linear search through all available files.
| InFileName | The name of the file to search for (must match exactly). |
| OutFileData | [out] The file data structure to populate if found. Will be empty if file is not found. |
| void UConfigForgeSubsystem::GetFileCategories | ( | const FConfigForgeFileData & | InFileData, |
| TArray< FName > & | OutCategories ) |
Retrieves all category names from a file data structure.
Extracts the names of all valid (non-null) categories from the provided file data. Only categories with valid pointers are included in the result.
| InFileData | The file data structure containing categories to extract. |
| OutCategories | [out] Array to populate with category names. Will be emptied before population. |
| void UConfigForgeSubsystem::GetFileCategoriesByName | ( | const FString & | InFileName, |
| TArray< FName > & | OutCategories ) |
Retrieves all category names from a file specified by name.
Convenience function that first looks up the file by name, then extracts all category names from that file. This combines GetFile() and GetFileCategories() operations.
| InFileName | The name of the file to retrieve categories from. |
| OutCategories | [out] Array to populate with category names. Will be emptied before population. |
| void UConfigForgeSubsystem::GetFileNames | ( | TArray< FString > & | OutNames | ) | const |
Retrieves the names of all configuration files in the setup asset.
Extracts and returns only the file names from all valid files in the setup asset. This is more efficient than GetFiles() when only names are needed.
| OutNames | [out] Array to populate with file names. Will be emptied before population. |
| void UConfigForgeSubsystem::GetFiles | ( | TArray< FConfigForgeFileData > & | OutFiles | ) | const |
Retrieves all valid configuration files from the setup asset.
Loads the setup asset synchronously and populates the output array with all files that have valid (non-null) File pointers. Null entries in the setup asset are automatically filtered out.
| OutFiles | [out] Array to populate with valid file data. Will be emptied before population. |
| bool UConfigForgeSubsystem::GetRuntimeCategories | ( | const UConfigForgeFileRuntime * | InConfigFile, |
| TArray< UConfigForgeCategoryRuntime * > & | OutCategories ) const |
Retrieves all categories from a specific runtime configuration file.
| InConfigFile | Pointer to the runtime configuration file to query. |
| OutCategories | [out] Array that will be populated with pointers to all categories in the file. |
| bool UConfigForgeSubsystem::GetRuntimeCategories_ID | ( | const FGuid & | InFileId, |
| TArray< UConfigForgeCategoryRuntime * > & | OutCategories ) const |
Retrieves all categories from a runtime configuration file identified by its GUID.
| InFileId | The unique identifier of the configuration file. |
| OutCategories | [out] Array that will be populated with pointers to all categories in the file. |
| bool UConfigForgeSubsystem::GetRuntimeCategory | ( | const UConfigForgeFileRuntime * | InConfigFile, |
| const FName & | InCategoryName, | ||
| UConfigForgeCategoryRuntime *& | OutCategory ) const |
Retrieves a specific category by name from a runtime configuration file.
| InConfigFile | Pointer to the runtime configuration file to query. |
| InCategoryName | The name of the category to retrieve. |
| OutCategory | [out] Pointer to the retrieved category if found. |
| bool UConfigForgeSubsystem::GetRuntimeCategory_ID | ( | const FGuid & | InFileId, |
| const FName & | InCategoryName, | ||
| UConfigForgeCategoryRuntime *& | OutCategory ) const |
Retrieves a specific category by name from a runtime configuration file identified by its GUID.
| InFileId | The unique identifier of the configuration file. |
| InCategoryName | The name of the category to retrieve. |
| OutCategory | [out] Pointer to the retrieved category if found. |
| bool UConfigForgeSubsystem::GetRuntimeField | ( | const UConfigForgeCategoryRuntime * | InRuntimeCategory, |
| const FString & | InKey, | ||
| UConfigValueObjectRuntime *& | OutField ) const |
Retrieves a specific field by key from a runtime category.
| InRuntimeCategory | Pointer to the runtime category to query. |
| InKey | The key identifier of the field to retrieve. |
| OutField | [out] Pointer to the retrieved field value object if found. |
| bool UConfigForgeSubsystem::GetRuntimeField_File | ( | const UConfigForgeFileRuntime * | InConfigFile, |
| const FName & | InCategoryName, | ||
| const FString & | InKey, | ||
| UConfigValueObjectRuntime *& | OutField ) const |
Retrieves a specific field by key from a category within a runtime configuration file.
| InConfigFile | Pointer to the runtime configuration file to query. |
| InCategoryName | The name of the category containing the field. |
| InKey | The key identifier of the field to retrieve. |
| OutField | [out] Pointer to the retrieved field value object if found. |
| bool UConfigForgeSubsystem::GetRuntimeField_Full | ( | const FGuid & | InFiledId, |
| const FName & | InCategoryName, | ||
| const FString & | InFieldName, | ||
| UConfigForgeFileRuntime *& | OutFile, | ||
| UConfigForgeCategoryRuntime *& | OutCategory, | ||
| UConfigValueObjectRuntime *& | OutField ) const |
Retrieves a runtime field by providing its file ID, category name, and field name.
This function performs a full lookup: first finding the file by ID, then the category within that file, and finally the specific field within the category. All three output pointers are set if successful.
| InFiledId | The unique GUID of the config file containing the field. |
| InCategoryName | The name of the category containing the field. |
| InFieldName | The name of the field to retrieve. |
| OutFile | [out] Pointer to the runtime file object if found (nullptr otherwise). |
| OutCategory | [out] Pointer to the runtime category object if found (nullptr otherwise). |
| OutField | [out] Pointer to the runtime field value object if found (nullptr otherwise). |
| bool UConfigForgeSubsystem::GetRuntimeField_ID | ( | const FGuid & | InFileID, |
| const FName & | InCategoryName, | ||
| const FString & | InKey, | ||
| UConfigValueObjectRuntime *& | OutField ) const |
Retrieves a specific field by key from a category within a runtime configuration file identified by its GUID.
| InFileID | The unique identifier of the configuration file. |
| InCategoryName | The name of the category containing the field. |
| InKey | The key identifier of the field to retrieve. |
| OutField | [out] Pointer to the retrieved field value object if found. |
| bool UConfigForgeSubsystem::GetRuntimeFields | ( | const UConfigForgeCategoryRuntime * | InRuntimeCategory, |
| TArray< UConfigValueObjectRuntime * > & | OutFields ) const |
Retrieves all fields from a runtime category.
| InRuntimeCategory | Pointer to the runtime category to query. |
| OutFields | [out] Array that will be populated with pointers to all field value objects in the category. |
| bool UConfigForgeSubsystem::GetRuntimeFields_File | ( | const UConfigForgeFileRuntime * | InConfigFile, |
| const FName & | InCategoryName, | ||
| TArray< UConfigValueObjectRuntime * > & | OutFields ) const |
Retrieves all fields from a category within a runtime configuration file.
| InConfigFile | Pointer to the runtime configuration file to query. |
| InCategoryName | The name of the category containing the fields. |
| OutFields | [out] Array that will be populated with pointers to all field value objects in the category. |
| bool UConfigForgeSubsystem::GetRuntimeFields_ID | ( | const FGuid & | InFileID, |
| const FName & | InCategoryName, | ||
| TArray< UConfigValueObjectRuntime * > & | OutFields ) const |
Retrieves all fields from a category within a runtime configuration file identified by its GUID.
| InFileID | The unique identifier of the configuration file. |
| InCategoryName | The name of the category containing the fields. |
| OutFields | [out] Array that will be populated with pointers to all field value objects in the category. |
| bool UConfigForgeSubsystem::GetRuntimeFile | ( | const FGuid & | InUniqueFileId, |
| UConfigForgeFileRuntime *& | OutRuntimeFile ) const |
Retrieves a loaded runtime file instance by its unique ID.
Searches the internal RuntimeFiles map for a valid UConfigForgeFileRuntime object associated with the given InUniqueFileId.
| InUniqueFileId | The unique GUID of the file to retrieve. |
| OutRuntimeFile | [out] Pointer to the runtime file object if found and valid. |
| const UConfigForgeDeveloperSettings * UConfigForgeSubsystem::GetSettings | ( | ) | const |
Gets the developer settings for the ConfigForge system.
Retrieves the default instance of UConfigForgeDeveloperSettings from the project settings. This provides access to the plugin's configuration options.
| TSoftObjectPtr< UConfigForgeSetup > UConfigForgeSubsystem::GetSetupAsset | ( | ) | const |
Retrieves the setup asset reference from developer settings.
Returns a soft object pointer to the UConfigForgeSetup asset that is configured in Project Settings -> Config Forge -> 'ConfigSetup'. This asset contains all file and category configurations for the system.
|
inline |
Checks whether a file load/save operation is currently in progress.
Used to prevent concurrent operations on the subsystem (reentrancy protection).
| bool UConfigForgeSubsystem::LoadAllFiles | ( | TArray< UConfigForgeFileRuntime * > & | OutFiles | ) |
Loads all configuration files synchronously.
Clears the output array and attempts to load every file defined in the ConfigForge setup asset. The files are loaded into runtime objects (UConfigForgeFileRuntime*) that hold the parsed data.
| OutFiles | [out] Array that will be populated with pointers to the loaded runtime file objects. The caller is responsible for managing the lifetime of these objects (they are owned by the subsystem). |
| void UConfigForgeSubsystem::LoadAllFilesAsync | ( | FLoadAllForgeFileDelegate | Callback | ) |
Loads all configuration files asynchronously.
Starts an asynchronous task on the task graph to load all files. When complete, the provided delegate is executed on the game thread with the results.
| Callback | Delegate called when the operation finishes. Signature: void(bool bSuccess, const TArray<UConfigForgeFileRuntime*>& LoadedFiles) |
|
protected |
Internal helper that loads multiple config files from structured data into runtime objects.
Iterates over the provided array of file data and attempts to read each file using ReadFileInternal. Successfully loaded runtime files are added to OutFiles.
| InDataArr | Array of file metadata and content to load. |
| OutFiles | [out] Array of successfully created runtime file objects. |
| bool UConfigForgeSubsystem::LoadSelectedFiles | ( | const TArray< FConfigForgeFileData > & | InFiles, |
| TArray< UConfigForgeFileRuntime * > & | OutFiles ) |
Synchronously loads a selected subset of config files into runtime objects.
This is a thread-safe wrapper around LoadAllFilesInternal that prevents concurrent file operations via the bOperatingFiles flag.
| InFiles | Array of file data describing which files to load. |
| OutFiles | [out] Array of loaded runtime file objects (empty on failure). |
| void UConfigForgeSubsystem::LoadSelectedFilesAsync | ( | const TArray< FConfigForgeFileData > & | InFiles, |
| FLoadAllForgeFileDelegate | Callback ) |
Asynchronously loads a selected subset of config files into runtime objects.
Runs the loading process on the task graph thread and executes the provided callback on the game thread when complete. Prevents concurrent operations using bOperatingFiles.
If a file operation is already in progress, the callback is immediately invoked with failure.
| InFiles | Array of file data describing which files to load. |
| Callback | Delegate called on the game thread when loading finishes. Parameters: (bool bSuccess, TArray<UConfigForgeFileRuntime*> LoadedFiles). |
| bool UConfigForgeSubsystem::LoadSingleFile | ( | const FConfigForgeFileData & | InFileData, |
| UConfigForgeFileRuntime *& | OutFile ) |
Synchronously loads a single config file from disk.
Blocks the calling thread and uses ReadFileInternal(). Fails immediately if another operation is already in progress (bOperatingFiles == true).
| InFileData | Structure containing the path provider class, file ID, and template asset. |
| OutFile | [out] The loaded runtime file object on success. |
| void UConfigForgeSubsystem::LoadSingleFileAsync | ( | const FConfigForgeFileData & | InFileData, |
| FLoadForgeFileDelegate | Callback ) |
Asynchronously loads a single config file from disk.
Runs the heavy I/O on the task graph thread and delivers the result back on the game thread. If another operation is in progress, the callback is called immediately with failure.
| InFileData | Structure containing the path provider class, file ID, and template asset. |
| Callback | Delegate called on the game thread with success flag and runtime file (or nullptr). |
|
protected |
Internal function that loads (and creates) a config file from disk.
This is the core implementation used by both synchronous and asynchronous load functions. It:
| InPathProviderClass | Class of the path provider determining where to read/write. |
| InId | Unique ID of the file to assign map key. |
| InTemplate | Template asset containing metadata (e.g., FileName) and default values. |
| OutFile | [out] The created/loaded runtime file object on success. |
| bool UConfigForgeSubsystem::SaveAllFiles | ( | ) |
Saves all currently loaded runtime configuration files synchronously.
Retrieves all runtime file objects currently managed by the subsystem and writes them to disk.
| void UConfigForgeSubsystem::SaveAllFilesAsync | ( | FSaveAllForgeFileDelegate | Callback | ) |
Saves all currently loaded runtime configuration files asynchronously.
Starts an asynchronous task on the task graph to save all managed runtime files. When complete, the provided delegate is executed on the game thread.
| Callback | Delegate called when the operation finishes. Signature: void(bool bSuccess) |
| bool UConfigForgeSubsystem::SaveSelectedFiles | ( | const TArray< FGuid > & | InFiles | ) |
Synchronously saves the specified files to disk.
Saves all valid files from the provided GUID array. Operation is performed immediately on the calling thread (usually game thread).
| InFiles | Array of file GUIDs to save |
| void UConfigForgeSubsystem::SaveSelectedFiles | ( | const TArray< FGuid > & | InFiles, |
| FSaveSelectedForgeFileDelegate | Callback ) |
Asynchronously saves the specified files and calls delegate upon completion.
Performs file saving on a background thread. After all operations are finished, broadcasts OnFileSaved for each file and executes the provided callback on the game thread.
| InFiles | Array of file GUIDs to save |
| Callback | Delegate that will be called on game thread when operation completes Signature: void(bool bSuccess, const TArray<UConfigForgeFileRuntime*>& SavedFiles) |
| bool UConfigForgeSubsystem::SaveSingleFile | ( | const FGuid & | InFileUniqueID | ) |
Synchronously saves a single loaded config file to disk.
Looks up the runtime file by ID, then calls WriteFileInternal(). Fails immediately if another operation is in progress or the file is not loaded.
| InFileUniqueID | The unique ID of the file to save. |
| void UConfigForgeSubsystem::SaveSingleFileAsync | ( | const FGuid & | InFileUniqueID, |
| FSaveForgeFileDelegate | Callback ) |
Asynchronously saves a single loaded config file to disk.
Runs the save operation on the task graph thread and reports back on the game thread. If another operation is in progress or the file is not loaded, the callback is called immediately with failure.
| InFileUniqueID | The unique ID of the file to save. |
| Callback | Delegate called on the game thread with success flag. |
|
protected |
Internal helper that writes multiple runtime config files to disk.
Iterates over the provided runtime files and calls WriteFileInternal on each valid one.
| InFiles | Array of runtime file objects to write. |
|
protected |
Internal function that writes a runtime file to disk.
Ensures the directory and file exist, then calls SaveTo() on the runtime file. Note: The current implementation has a bug — it calls ReadFrom() instead of SaveTo(). This function is intended to save the in-memory data to disk.
| InFile | The runtime file to write. |