Cogs.Core
Public Member Functions | Private Attributes | List of all members
Cogs::Core::Variables Class Reference

Manages runtime variables for the engine. More...

#include <Variables.h>

Public Member Functions

 Variables (const char **variables, int count)
 
void initialize (const ResourceStore &resourceStore)
 
Variableset (const StringView &name, const StringView &value)
 
Variableset (const StringView &name, const char *value)
 
Variableset (const StringView &name, int value)
 
Variableset (const StringView &name, float value)
 
Variableset (const StringView &name, double value)
 
Variableset (const StringView &name, bool value)
 
Variableset (const StringView &name, glm::vec2 value)
 
Variableset (const StringView &name, glm::vec3 value)
 
Variableset (const StringView &name, glm::vec4 value)
 
const Variableget (const StringView &name) const
 Retrieve a pointer to the variable with the given name.
 
VariablegetIfExists (const StringView &name)
 Get a pointer to a variable if it exists, otherwise nullptr. Does not modify set of variables.
 
Variableget (const StringView &name)
 Retrieve a pointer to the variable with the given name.
 
bool erase (const StringView &name)
 Remove a set variable (so it will revert to default).
 
bool exist (const StringView &name)
 Check if a variable exists.
 
const StringView get (const StringView &name, StringView defaultValue) const
 
const char * get (const StringView &name, const char *defaultValue) const
 
bool get (const StringView &name, bool defaultValue) const
 
float get (const StringView &name, float defaultValue) const
 
double get (const StringView &name, double defaultValue) const
 
int get (const StringView &name, int defaultValue) const
 
glm::vec2 get (const StringView &name, glm::vec2 defaultValue) const
 
glm::vec3 get (const StringView &name, glm::vec3 defaultValue) const
 
glm::vec4 get (const StringView &name, glm::vec4 defaultValue) const
 
bool getOrAdd (const StringView &name, bool defaultValue)
 
void getMatchingVariables (std::vector< const Variable * > &vars, const StringView &keyPrefix)
 
Variableoperator[] (const StringView &key)
 
std::unordered_map< size_t, Variable > & getVariables ()
 

Private Attributes

std::unordered_map< size_t, Variablevariables
 Variable store.
 
Variable empty
 Empty variable, returned on invalid queries.
 

Detailed Description

Manages runtime variables for the engine.

Definition at line 102 of file Variables.h.

Constructor & Destructor Documentation

◆ Variables()

Cogs::Core::Variables::Variables ( const char **  variables,
int  count 
)

Definition at line 57 of file Variables.cpp.

Member Function Documentation

◆ erase()

bool Cogs::Core::Variables::erase ( const StringView name)

Remove a set variable (so it will revert to default).

Definition at line 100 of file Variables.cpp.

References Cogs::StringView::hash().

◆ exist()

bool Cogs::Core::Variables::exist ( const StringView name)
inline

Check if a variable exists.

Definition at line 132 of file Variables.h.

References Cogs::StringView::hash().

◆ get() [1/11]

Cogs::Core::Variable * Cogs::Core::Variables::get ( const StringView name)

Retrieve a pointer to the variable with the given name.

Definition at line 124 of file Variables.cpp.

References Cogs::StringView::hash().

◆ get() [2/11]

const Cogs::Core::Variable * Cogs::Core::Variables::get ( const StringView name) const

Retrieve a pointer to the variable with the given name.

Definition at line 109 of file Variables.cpp.

References Cogs::StringView::hash().

◆ get() [3/11]

bool Cogs::Core::Variables::get ( const StringView name,
bool  defaultValue 
) const
inline

Definition at line 136 of file Variables.h.

◆ get() [4/11]

const char * Cogs::Core::Variables::get ( const StringView name,
const char *  defaultValue 
) const
inline

Definition at line 135 of file Variables.h.

◆ get() [5/11]

double Cogs::Core::Variables::get ( const StringView name,
double  defaultValue 
) const
inline

Definition at line 138 of file Variables.h.

◆ get() [6/11]

float Cogs::Core::Variables::get ( const StringView name,
float  defaultValue 
) const
inline

Definition at line 137 of file Variables.h.

◆ get() [7/11]

glm::vec2 Cogs::Core::Variables::get ( const StringView name,
glm::vec2  defaultValue 
) const
inline

Definition at line 140 of file Variables.h.

◆ get() [8/11]

glm::vec3 Cogs::Core::Variables::get ( const StringView name,
glm::vec3  defaultValue 
) const
inline

Definition at line 141 of file Variables.h.

◆ get() [9/11]

glm::vec4 Cogs::Core::Variables::get ( const StringView name,
glm::vec4  defaultValue 
) const
inline

Definition at line 142 of file Variables.h.

◆ get() [10/11]

int Cogs::Core::Variables::get ( const StringView name,
int  defaultValue 
) const
inline

Definition at line 139 of file Variables.h.

◆ get() [11/11]

const Cogs::StringView Cogs::Core::Variables::get ( const StringView name,
StringView  defaultValue 
) const

Definition at line 45 of file Variables.cpp.

◆ getIfExists()

Cogs::Core::Variable * Cogs::Core::Variables::getIfExists ( const StringView name)

Get a pointer to a variable if it exists, otherwise nullptr. Does not modify set of variables.

Definition at line 116 of file Variables.cpp.

References Cogs::StringView::hash().

◆ getMatchingVariables()

void Cogs::Core::Variables::getMatchingVariables ( std::vector< const Variable * > &  vars,
const StringView keyPrefix 
)

Definition at line 140 of file Variables.cpp.

◆ getOrAdd()

bool Cogs::Core::Variables::getOrAdd ( const StringView name,
bool  defaultValue 
)
inline

Definition at line 144 of file Variables.h.

◆ getVariables()

std::unordered_map< size_t, Variable > & Cogs::Core::Variables::getVariables ( )
inline

Definition at line 157 of file Variables.h.

◆ initialize()

void Cogs::Core::Variables::initialize ( const ResourceStore resourceStore)

Definition at line 78 of file Variables.cpp.

◆ operator[]()

Cogs::Core::Variable & Cogs::Core::Variables::operator[] ( const StringView key)

Definition at line 135 of file Variables.cpp.

◆ set() [1/9]

Variable * Cogs::Core::Variables::set ( const StringView name,
bool  value 
)
inline

Definition at line 114 of file Variables.h.

◆ set() [2/9]

Variable * Cogs::Core::Variables::set ( const StringView name,
const char *  value 
)
inline

Definition at line 110 of file Variables.h.

◆ set() [3/9]

Variable * Cogs::Core::Variables::set ( const StringView name,
const StringView value 
)
inline

Definition at line 109 of file Variables.h.

◆ set() [4/9]

Variable * Cogs::Core::Variables::set ( const StringView name,
double  value 
)
inline

Definition at line 113 of file Variables.h.

◆ set() [5/9]

Variable * Cogs::Core::Variables::set ( const StringView name,
float  value 
)
inline

Definition at line 112 of file Variables.h.

◆ set() [6/9]

Variable * Cogs::Core::Variables::set ( const StringView name,
glm::vec2  value 
)
inline

Definition at line 115 of file Variables.h.

◆ set() [7/9]

Variable * Cogs::Core::Variables::set ( const StringView name,
glm::vec3  value 
)
inline

Definition at line 116 of file Variables.h.

◆ set() [8/9]

Variable * Cogs::Core::Variables::set ( const StringView name,
glm::vec4  value 
)
inline

Definition at line 117 of file Variables.h.

◆ set() [9/9]

Variable * Cogs::Core::Variables::set ( const StringView name,
int  value 
)
inline

Definition at line 111 of file Variables.h.

Member Data Documentation

◆ empty

Variable Cogs::Core::Variables::empty
private

Empty variable, returned on invalid queries.

Definition at line 164 of file Variables.h.

◆ variables

std::unordered_map<size_t, Variable> Cogs::Core::Variables::variables
private

Variable store.

Definition at line 161 of file Variables.h.


The documentation for this class was generated from the following files: