XII Release 0.1.0
Loading...
Searching...
No Matches
xiiConfigFileResource Class Reference

#include <ConfigFileResource.h>

Inheritance diagram for xiiConfigFileResource:
[legend]

Public Member Functions

xiiInt32 GetInt (xiiTempHashedString sName) const
 Returns the 'int' variable with the given name. Logs an error, if the variable doesn't exist in the config file.
float GetFloat (xiiTempHashedString sName) const
 Returns the 'float' variable with the given name. Logs an error, if the variable doesn't exist in the config file.
double GetDouble (xiiTempHashedString sName) const
 Returns the 'double' variable with the given name. Logs an error, if the variable doesn't exist in the config file.
bool GetBool (xiiTempHashedString sName) const
 Returns the 'bool' variable with the given name. Logs an error, if the variable doesn't exist in the config file.
const char * GetString (xiiTempHashedString sName) const
 Returns the 'string' variable with the given name. Logs an error, if the variable doesn't exist in the config file.
xiiInt32 GetInt (xiiTempHashedString sName, xiiInt32 iFallback) const
 Returns the 'int' variable with the given name. Returns the 'fallback' value, if the variable doesn't exist in the config file.
float GetFloat (xiiTempHashedString sName, float fFallback) const
 Returns the 'float' variable with the given name. Returns the 'fallback' value, if the variable doesn't exist in the config file.
double GetDouble (xiiTempHashedString sName, double fFallback) const
 Returns the 'double' variable with the given name. Returns the 'fallback' value, if the variable doesn't exist in the config file.
bool GetBool (xiiTempHashedString sName, bool bFallback) const
 Returns the 'bool' variable with the given name. Returns the 'fallback' value, if the variable doesn't exist in the config file.
const char * GetString (xiiTempHashedString sName, const char *szFallback) const
 Returns the 'string' variable with the given name. Returns the 'fallback' value, if the variable doesn't exist in the config file.
Public Member Functions inherited from xiiResource
XII_ALWAYS_INLINE xiiStringView GetResourceID () const
XII_ALWAYS_INLINE xiiUInt64 GetResourceIDHash () const
 Returns the hash of the unique ID.
void SetResourceDescription (xiiStringView sDescription)
const xiiString & GetResourceDescription () const
const xiiString & GetResourceIdOrDescription () const
XII_ALWAYS_INLINE xiiResourceState GetLoadingState () const
 Returns the current state in which this resource is in.
XII_ALWAYS_INLINE xiiUInt8 GetNumQualityLevelsDiscardable () const
XII_ALWAYS_INLINE xiiUInt8 GetNumQualityLevelsLoadable () const
 Returns how many quality levels the resource may additionally load.
float GetLoadingPriority (xiiTime now) const
 Returns the priority that is used by the resource manager to determine which resource to load next.
xiiResourcePriority GetPriority () const
 Returns the current resource priority.
void SetPriority (xiiResourcePriority priority)
 Changes the current resource priority.
XII_ALWAYS_INLINE const xiiBitflags< xiiResourceFlags > & GetBaseResourceFlags () const
 Returns the basic flags for the resource type. Mostly used the resource manager.
XII_ALWAYS_INLINE const MemoryUsage & GetMemoryUsage () const
 Returns the information about the current memory usage of the resource.
XII_ALWAYS_INLINE xiiTime GetLastAcquireTime () const
XII_ALWAYS_INLINE xiiInt32 GetReferenceCount () const
 Returns the reference count of this resource.
XII_ALWAYS_INLINE const xiiTimestamp & GetLoadedFileModificationTime () const
XII_ALWAYS_INLINE xiiUInt32 GetCurrentResourceChangeCounter () const
XII_ALWAYS_INLINE void IncResourceChangeCounter ()
 Allows to manually increase the resource change counter to signal that dependent code might need to update.
virtual void ResetResource ()
void PrintHandleStackTraces ()
Public Member Functions inherited from xiiReflectedClass
virtual const xiiRTTI * GetDynamicRTTI () const
bool IsInstanceOf (const xiiRTTI *pType) const
 Returns whether the type of this instance is of the given type or derived from it.
template<typename T>
XII_ALWAYS_INLINE bool IsInstanceOf () const
 Returns whether the type of this instance is of the given type or derived from it.

Protected Member Functions

virtual xiiResourceLoadDescription UnloadData (Unload WhatToUnload) override
virtual xiiResourceLoadDescription UpdateContent (xiiStreamReader *Stream) override
virtual void UpdateMemoryUsage (MemoryUsage &out_NewMemoryUsage) override
Protected Member Functions inherited from xiiResource
 xiiResource (DoUpdate resourceUpdateThread, xiiUInt8 uiQualityLevelsLoadable)
 Default constructor.
virtual ~xiiResource ()
 virtual destructor.
MemoryUsage & ModifyMemoryUsage ()
 Non-const version for resources that want to write this variable directly.
void SetIsReloadable (bool bIsReloadable)
void SetHasLoadingFallback (bool bHasLoadingFallback)
 Used internally by the code injection macros.

Friends

class xiiConfigFileResourceLoader

Additional Inherited Members

Public Types inherited from xiiResource
enum class  DoUpdate : xiiUInt8 { OnMainThread = 0U , OnAnyThread }
 Specifies the thread type on which update operations should be performed. More...
Static Public Member Functions inherited from xiiNoBase
static const xiiRTTI * GetStaticRTTI ()
Public Attributes inherited from xiiResource
xiiEvent< const xiiResourceEvent &, xiiMutex > m_ResourceEvents
Protected Types inherited from xiiResource
enum class  Unload : xiiUInt8 { AllQualityLevels = 0U , OneQualityLevel }

Detailed Description

This resource loads config files containing key/value pairs

The config files usually use the file extension '.xiiConfig'.

The file format looks like this:

To declare a key/value pair for the first time, write its type, name and value: int i = 1 float f = 2.3 bool b = false string s = "hello"

To set a variable to a different value than before, it has to be marked with 'override':

override i = 4

The format supports C preprocessor features like #include, #define, #ifdef, etc. This can be used to build hierarchical config files:

#include "BaseConfig.xiiConfig" override int SomeValue = 7

It can also be used to define 'enum types':

#define SmallValue 3 #define BigValue 5 int MyValue = BigValue

Since resources can be reloaded at runtime, config resources are a convenient way to define game parameters that you may want to tweak at any time. Using C preprocessor logic (#define, if, #else, etc) you can quickly select between different configuration sets.

Once loaded, accessing the data is very efficient.

Member Function Documentation

◆ UnloadData()

xiiResourceLoadDescription xiiConfigFileResource::UnloadData ( Unload WhatToUnload)
overrideprotectedvirtual

Requests the resource to unload another quality level. If bFullUnload is true, the resource should unload all data, because it is going to be deleted afterwards.

Implements xiiResource.

◆ UpdateContent()

xiiResourceLoadDescription xiiConfigFileResource::UpdateContent ( xiiStreamReader * pStream)
overrideprotectedvirtual

Called whenever more data for the resource is available. The resource must read the stream to update it's data.

pStream may be nullptr in case the resource data could not be found.

Implements xiiResource.

◆ UpdateMemoryUsage()

void xiiConfigFileResource::UpdateMemoryUsage ( MemoryUsage & out_NewMemoryUsage)
overrideprotectedvirtual

This function must be overridden by all resource types.

It has to compute the memory used by this resource. It is called by the resource manager whenever the resource's data has been loaded or unloaded.

Implements xiiResource.


The documentation for this class was generated from the following files:
  • /home/runner/work/XII/XII/Source/Engine/Utilities/Resources/ConfigFileResource.h
  • /home/runner/work/XII/XII/Source/Engine/Utilities/Resources/ConfigFileResource.cpp