This class implements Console Variables ("convars"). More...
#include "ConVar.hpp"
Public Types | |
enum | TypeT { String, Integer, Bool, Double } |
enum | FlagT { FLAG_ALL = -1, FLAG_MAIN_EXE = 0x0001, FLAG_MATSYS = 0x0002, FLAG_SOUNDSYS = 0x0004, FLAG_GAMEDLL = 0x0008, FLAG_USERINFO = 0x0010, FLAG_SERVERINFO = 0x0020, FLAG_NETWORK_SYNC = 0x0040, FLAG_CHEAT = 0x0080, FLAG_FOR_INIT = 0x0100, FLAG_READ_ONLY = 0x0200, FLAG_BY_CODE = 0x0400, FLAG_PERSISTENT = 0x0800 } |
Static Public Member Functions | |
static void | RegisterStaticList () |
Registers all convars in the StaticList with the ConsoleInterpreter and invalidates the StaticList. More... | |
Friends | |
class | ConsoleInterpreterImplT |
Give the implementation of the console interpreter full access. More... | |
This class implements Console Variables ("convars").
A convar is a special variable that can be modified by the user at the game console and is globally accessible in the entire application.
In user code, a convar can be declared as a global variable or as a local, static variable. Use as a non-static local variable or on the heap (with new and delete) is also possible, but comes at a performance cost and is against the (gobal) nature of convars. Such a local variable would also never be visible at the console, and thus it makes no sense to have it.
a) Before ConVarT::RegisterStaticList() is called, all instantiated convars register themselves in a list that is global to the module, that is, the exe and each dll has its own list. b) Then, the ConsoleInterpreter pointer is set to point to the implementation of the ConsoleInterpreterI in the exe. (There is only exactly one "global" singleton ConsoleInterpreterI instance for the entire application.) c) Calling ConVarT::RegisterStaticList() then iterates over all (pointers to) convars in the per-module list, and for each tries to find a convar with the same name in the unique, application-global list inside the ConsoleInterpreter. d) Convars that are instantiated after the call to ConVarT::RegisterStaticList(), e.g. local static variables that are reached by the control-flow for the first time, automatically register themselves with the ConsoleInterpreter directly, rather than attempting to add themselves to the obsolete list from step a).
enum ConVarT::FlagT |
|
static |
Registers all convars in the StaticList with the ConsoleInterpreter and invalidates the StaticList.
This has to be called after the ConsoleInterpreter pointer is set when the dll is first initialized! The ctors of all convars that are instantiated after this call (those that are declared as local (static) variables) then automatically register themselves with the ConsoleInterpreter rather than with the StaticList.
|
friend |
Give the implementation of the console interpreter full access.