The internal definition of a ConfigVariable. More...
#include "configVariableCore.h"
Public Member Functions | |
bool | clear_local_value () |
Removes the local value defined for this variable, and allows its value to be once again retrieved from the .prc files. More... | |
const ConfigDeclaration * | get_declaration (size_t n) const |
const ConfigDeclaration * | get_default_value () const |
const std::string & | get_description () const |
int | get_flags () const |
Returns the flags value as set by set_flags(). More... | |
const std::string & | get_name () const |
size_t | get_num_declarations () const |
size_t | get_num_references () const |
size_t | get_num_trusted_references () const |
size_t | get_num_unique_references () const |
const ConfigDeclaration * | get_reference (size_t n) const |
int | get_trust_level () const |
const ConfigDeclaration * | get_trusted_reference (size_t n) const |
const ConfigDeclaration * | get_unique_reference (size_t n) const |
ValueType | get_value_type () const |
bool | has_local_value () const |
Returns true if this variable's value has been shadowed by a local assignment (as created via make_local_value()), or false otherwise. More... | |
bool | has_value () const |
Returns true if this variable has an explicit value, either from a prc file or locally set, or false if variable has its default value. More... | |
bool | is_closed () const |
bool | is_dynamic () const |
bool | is_used () const |
ConfigDeclaration * | make_local_value () |
Creates a new local value for this variable, if there is not already one specified. More... | |
void | output (std::ostream &out) const |
void | set_default_value (const std::string &default_value) |
void | set_description (const std::string &description) |
void | set_flags (int flags) |
Specifies the trust level of this variable. More... | |
void | set_used () |
Marks that the variable has been "declared" by a ConfigVariable. More... | |
void | set_value_type (ValueType value_type) |
void | write (std::ostream &out) const |
Public Attributes | |
get_declaration | |
Returns the nth declarations that contributes to this variable's value. More... | |
get_default_value | |
Returns the default variable specified for this variable. More... | |
get_description | |
Returns the brief description of this variable, if it has been defined. More... | |
get_name | |
Returns the name of the variable. More... | |
get_num_declarations | |
Returns the number of declarations that contribute to this variable's value. More... | |
get_num_references | |
Returns the number of prc files that reference this variable. More... | |
get_num_trusted_references | |
Returns the number of trusted prc files that reference this variable. More... | |
get_num_unique_references | |
Returns the number of trusted, unique (by string value) values there exist for this variable. More... | |
get_reference | |
Returns the nth declaration in a prc file that references this variable. More... | |
get_trust_level | |
Returns the minimum trust_level a prc file must demonstrate in order to redefine the value for this variable. More... | |
get_trusted_reference | |
Returns the nth declaration in a trusted prc file that references this variable. More... | |
get_unique_reference | |
Returns the nth trusted, unique value for this variable. More... | |
get_value_type | |
Returns the stated type of this variable. More... | |
is_closed | |
Returns true if the variable is not trusted by any prc file (and hence cannot be modified from its compiled-in default value), or false for the normal case, in which the variable can be modified by any prc file at or above its trust level (see get_trust_level()). More... | |
is_dynamic | |
Returns true if the variable was indicated as "dynamic" by its constructor, indicating that its name was dynamically generated, possibly from a large pool, and it should not be listed along with the other variables. More... | |
is_used | |
Returns true if the variable has been referenced by a ConfigVariable somewhere in code, false otherwise. More... | |
set_default_value | |
Specifies the default value for this variable if it is not defined in any prc file. More... | |
set_description | |
Specifies the one-line description of this variable. More... | |
set_value_type | |
Specifies the type of this variable. More... | |
Friends | |
class | ConfigDeclaration |
class | ConfigVariableManager |
Additional Inherited Members | |
Public Types inherited from ConfigFlags | |
enum | ValueType { VT_undefined, VT_list, VT_string, VT_filename, VT_bool, VT_int, VT_double, VT_enum, VT_search_path, VT_int64, VT_color } |
enum | VariableFlags { F_trust_level_mask = 0x00000fff, F_open = 0x00001000, F_closed = 0x00002000, F_dynamic = 0x00004000, F_dconfig = 0x00008000 } |
The internal definition of a ConfigVariable.
This object is shared between all instances of a ConfigVariable that use the same variable name.
You cannot create a ConfigVariableCore instance directly; instead, use the make() method, which may return a shared instance. Once created, these objects are never destructed.
Definition at line 34 of file configVariableCore.h.
bool ConfigVariableCore::clear_local_value | ( | ) |
Removes the local value defined for this variable, and allows its value to be once again retrieved from the .prc files.
Returns true if the value was successfully removed, false if it did not exist in the first place.
Definition at line 257 of file configVariableCore.cxx.
References ConfigPage::delete_declaration(), and ConfigPage::get_local_page().
|
inline |
Returns the flags value as set by set_flags().
This includes the trust level and some other settings. See the individual methods is_closed(), get_trust_level(), etc. to pull out the semantic meaning of these flags individually.
Definition at line 55 of file configVariableCore.I.
|
inline |
Returns true if this variable's value has been shadowed by a local assignment (as created via make_local_value()), or false otherwise.
Definition at line 120 of file configVariableCore.I.
Referenced by has_value().
bool ConfigVariableCore::has_value | ( | ) | const |
Returns true if this variable has an explicit value, either from a prc file or locally set, or false if variable has its default value.
Definition at line 273 of file configVariableCore.cxx.
References has_local_value().
ConfigDeclaration * ConfigVariableCore::make_local_value | ( | ) |
Creates a new local value for this variable, if there is not already one specified.
This will shadow any values defined in the various .prc files.
If there is already a local value defined for this variable, simply returns that one.
Use clear_local_value() to remove the local value definition.
Definition at line 232 of file configVariableCore.cxx.
References get_declaration, ConfigPage::get_local_page(), is_closed, and ConfigPage::make_declaration().
void ConfigVariableCore::set_flags | ( | int | flags | ) |
Specifies the trust level of this variable.
See get_flags(). It is not an error to call this multiple times, but if the value changes once get_declaration() has been called, a warning is printed.
Definition at line 111 of file configVariableCore.cxx.
Referenced by ConfigVariableManager::make_variable_template().
|
inline |
Marks that the variable has been "declared" by a ConfigVariable.
Definition at line 111 of file configVariableCore.I.
Referenced by ConfigVariableManager::make_variable_template().
const ConfigDeclaration * ConfigVariableCore::get_declaration |
Returns the nth declarations that contributes to this variable's value.
The declarations are arranged in order such that earlier declarations shadow later declarations; thus, get_declaration(0) is always defined and always returns the current value of the variable.
Definition at line 65 of file configVariableCore.h.
Referenced by make_local_value().
|
inline |
Returns the default variable specified for this variable.
If the variable has not yet been defined, this will return NULL.
Definition at line 91 of file configVariableCore.h.
Referenced by ConfigVariableManager::make_variable_template().
|
inline |
Returns the brief description of this variable, if it has been defined.
Definition at line 90 of file configVariableCore.h.
|
inline |
Returns the name of the variable.
Definition at line 83 of file configVariableCore.h.
size_t ConfigVariableCore::get_num_declarations |
Returns the number of declarations that contribute to this variable's value.
If the variable has been defined, this will always be at least 1 (for the default value, at least).
Definition at line 65 of file configVariableCore.h.
|
inline |
Returns the number of prc files that reference this variable.
This is not exactly the same as the number of declarations; see get_reference().
Definition at line 69 of file configVariableCore.h.
|
inline |
Returns the number of trusted prc files that reference this variable.
See also get_num_references().
Definition at line 73 of file configVariableCore.h.
Referenced by ConfigVariableManager::write_prc_variables().
|
inline |
Returns the number of trusted, unique (by string value) values there exist for this variable.
Definition at line 77 of file configVariableCore.h.
|
inline |
Returns the nth declaration in a prc file that references this variable.
This is similar, but not identical to, get_declaration(). The difference is that this will list *only* true references in a prc file, and will not list default values or locally-assigned values; it also will list even the untrusted files.
Definition at line 69 of file configVariableCore.h.
|
inline |
Returns the minimum trust_level a prc file must demonstrate in order to redefine the value for this variable.
Arguably, this should be called the "mistrust level", since the larger the value, the more suspicious we are of prc files. This value is not used if is_closed() returns true, which indicates no file may be trusted.
This value only has effect in a release build (specifically, when PRC_RESPECT_TRUST_LEVEL is defined true in Config.pp).
Definition at line 86 of file configVariableCore.h.
|
inline |
Returns the nth declaration in a trusted prc file that references this variable.
This is similar, but not identical to, get_declaration(). The difference is that this will list *only* true references in a prc file, and will not list default values or locally-assigned values.
This is also similar to get_reference(), except that it only lists the trusted declarations, omitting the untrusted ones.
Definition at line 73 of file configVariableCore.h.
|
inline |
Returns the nth trusted, unique value for this variable.
This is similar to get_trusted_reference(), except that duplicate values are removed.
Definition at line 77 of file configVariableCore.h.
|
inline |
Returns the stated type of this variable.
If the variable has not yet been defined, this will be VT_undefined.
Definition at line 89 of file configVariableCore.h.
Referenced by ConfigVariableManager::write_prc_variables().
|
inline |
Returns true if the variable is not trusted by any prc file (and hence cannot be modified from its compiled-in default value), or false for the normal case, in which the variable can be modified by any prc file at or above its trust level (see get_trust_level()).
This value only has effect in a release build (specifically, when PRC_RESPECT_TRUST_LEVEL is defined true in Config.pp).
Definition at line 85 of file configVariableCore.h.
Referenced by make_local_value().
|
inline |
Returns true if the variable was indicated as "dynamic" by its constructor, indicating that its name was dynamically generated, possibly from a large pool, and it should not be listed along with the other variables.
Definition at line 87 of file configVariableCore.h.
Referenced by ConfigVariableManager::list_dynamic_variables(), and ConfigVariableManager::list_variables().
|
inline |
Returns true if the variable has been referenced by a ConfigVariable somewhere in code, false otherwise.
Definition at line 84 of file configVariableCore.h.
Referenced by ConfigVariableManager::list_dynamic_variables(), ConfigVariableManager::list_unused_variables(), and ConfigVariableManager::list_variables().
void ConfigVariableCore::set_default_value |
Specifies the default value for this variable if it is not defined in any prc file.
Definition at line 91 of file configVariableCore.h.
Referenced by ConfigVariableManager::make_variable_template().
void ConfigVariableCore::set_description |
Specifies the one-line description of this variable.
See get_description(). It is not an error to call this multiple times, but if the value changes once get_declaration() has been called, a warning is printed.
Definition at line 90 of file configVariableCore.h.
Referenced by ConfigVariableManager::make_variable_template().
void ConfigVariableCore::set_value_type |
Specifies the type of this variable.
See get_value_type(). It is not an error to call this multiple times, but if the value changes once get_declaration() has been called, a warning is printed.
Definition at line 89 of file configVariableCore.h.
Referenced by ConfigVariableManager::make_variable_template().