ICVar

#include

Public Types

enum EConsoleLogMode { eCLM_Off, eCLM_ConsoleAndFile, eCLM_FileOnly, eCLM_FullInfo }
typedef std::function< void(void)> CallbackFunction

Public Member Functions

virtual void Release ()=0
virtual int GetIVal () const =0
virtual int64 GetI64Val () const =0
virtual float GetFVal () const =0
virtual const char * GetString () const =0
virtual const char * GetDataProbeString () const =0
virtual void Set (const char *s)=0
virtual void ForceSet (const char *s)=0
virtual void Set (const float f)=0
virtual void Set (const int i)=0
virtual void ClearFlags (int flags)=0
Clear the specified bits in the flag field.
virtual int GetFlags () const =0
virtual int SetFlags (int flags)=0
Set the variable's flags.
virtual int GetType ()=0
virtual const char * GetName () const =0
virtual const char * GetHelp ()=0
virtual bool IsConstCVar () const =0
virtual void SetOnChangeCallback (ConsoleVarFunc pChangeFunc)=0
virtual uint64 AddOnChangeFunctor (const SFunctor &pChangeFunctor)=0
uint64 AddOnChange (const CallbackFunction &callback)
virtual uint64 GetNumberOfOnChangeFunctors () const =0
virtual const SFunctor & GetOnChangeFunctor (uint64 nFunctorIndex) const =0
Returns the number of registered on change functors.
virtual bool RemoveOnChangeFunctor (const uint64 nElement)=0
virtual ConsoleVarFunc GetOnChangeCallback () const =0
Get the current callback function.
virtual void GetMemoryUsage (class ICrySizer *pSizer) const =0
virtual int GetRealIVal () const =0
virtual void DebugLog (const int iExpectedValue, const EConsoleLogMode mode) const
Log difference between expected state and real state. Only useful for CVarGroups.

Detailed Description

This interface is the 1:1 "C++ representation" of a console variable.

Note
A console variable is accessible in C++ trough this interface and in all scripts as global variable (with the same name of the variable in the console).

Member Enumeration Documentation

◆ EConsoleLogMode

Enumerator
eCLM_Off

Off.

eCLM_ConsoleAndFile

Normal info to console and file.

eCLM_FileOnly

Normal info to file only.

eCLM_FullInfo

Full info to file only.

Member Function Documentation

◆ AddOnChange()

uint64 ICVar::AddOnChange ( const CallbackFunction & callback)
inline

Adds a new on change callback function to the cvar. It will add from index 1 on (0 is reserved).

◆ AddOnChangeFunctor()

virtual uint64 ICVar::AddOnChangeFunctor ( const SFunctor & pChangeFunctor)
pure virtual

Adds a new on change functor to the list. It will add from index 1 on (0 is reserved).

◆ ForceSet()

virtual void ICVar::ForceSet ( const char * s)
pure virtual

Force to set the string value of the variable - can only be called from inside code.

Parameters
sString representation the value.

◆ GetDataProbeString()

virtual const char* ICVar::GetDataProbeString ( ) const
pure virtual
Note
Don't store pointer as multiple calls to this function might return same memory ptr.
Returns
The data probe string value of the variable.

◆ GetFlags()

virtual int ICVar::GetFlags ( ) const
pure virtual

Return the variable's flags.

Returns
the variable's flags.

◆ GetFVal()

virtual float ICVar::GetFVal ( ) const
pure virtual
Returns
The float value of the variable.

◆ GetHelp()

virtual const char* ICVar::GetHelp ( )
pure virtual
Returns
The variable's help text, can be NULL if no help is available.

◆ GetI64Val()

virtual int64 ICVar::GetI64Val ( ) const
pure virtual
Returns
The 64-bit integer value of the variable.

◆ GetIVal()

virtual int ICVar::GetIVal ( ) const
pure virtual
Returns
Value of the variable as an integer.

◆ GetName()

virtual const char* ICVar::GetName ( ) const
pure virtual
Returns
The variable's name.

◆ GetNumberOfOnChangeFunctors()

virtual uint64 ICVar::GetNumberOfOnChangeFunctors ( ) const
pure virtual
Returns
The number of registered on change functos.

◆ GetRealIVal()

virtual int ICVar::GetRealIVal ( ) const
pure virtual

Only useful for CVarGroups, other types return GetIVal(). CVarGroups set multiple other CVars and this function returns the integer value the CVarGroup should have, when looking at the controlled cvars.

Returns
Value that would represent the state, -1 if the state cannot be found

◆ GetString()

virtual const char* ICVar::GetString ( ) const
pure virtual
Note
Don't store pointer as multiple calls to this function might return same memory ptr.
Returns
The string value of the variable.

◆ GetType()

virtual int ICVar::GetType ( )
pure virtual
Returns
the primary variable's type, e.g. CVAR_INT, CVAR_FLOAT, CVAR_STRING.

◆ IsConstCVar()

virtual bool ICVar::IsConstCVar ( ) const
pure virtual
Returns
true if the variable may be modified in config files.

◆ Release()

virtual void ICVar::Release ( )
pure virtual

Delete the variable.

Note
The variable will automatically unregister itself from the console.

◆ RemoveOnChangeFunctor()

virtual bool ICVar::RemoveOnChangeFunctor ( const uint64 nElement)
pure virtual

Removes an on change functor.

Returns
true if removal was successful.

◆ Set() [1/3]

virtual void ICVar::Set ( const char * s)
pure virtual

Set the string value of the variable.

Parameters
sString representation the value.

◆ Set() [2/3]

virtual void ICVar::Set ( const float f)
pure virtual

Set the float value of the variable.

Parameters
sFloat representation the value.

◆ Set() [3/3]

virtual void ICVar::Set ( const int i)
pure virtual

Set the float value of the variable.

Parameters
sinteger representation the value.

◆ SetOnChangeCallback()

virtual void ICVar::SetOnChangeCallback ( ConsoleVarFunc pChangeFunc)
pure virtual

Set a new on change function callback.

Note
Deprecated function. The functor should be preferred.