ConfigVariableCore
-
class ConfigVariableCore
Bases:
ConfigFlags
The internal definition of a
ConfigVariable
. This object is shared between all instances of aConfigVariable
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.
Inheritance diagram
-
bool clear_local_value(void)
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.
-
ConfigDeclaration const *get_declaration(std::size_t n) const
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.
-
ConfigDeclaration const *get_default_value(void) const
Returns the default variable specified for this variable. If the variable has not yet been defined, this will return NULL.
-
std::string const &get_description(void) const
Returns the brief description of this variable, if it has been defined.
-
int get_flags(void) const
Returns the flags value as set by
set_flags()
. This includes the trust level and some other settings. See the individual methodsis_closed()
,get_trust_level()
, etc. to pull out the semantic meaning of these flags individually.
-
std::string const &get_name(void) const
Returns the name of the variable.
-
std::size_t get_num_declarations(void) const
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).
-
std::size_t get_num_references(void) const
Returns the number of prc files that reference this variable. This is not exactly the same as the number of declarations; see
get_reference()
.
-
std::size_t get_num_trusted_references(void) const
Returns the number of trusted prc files that reference this variable. See also
get_num_references()
.
-
std::size_t get_num_unique_references(void) const
Returns the number of trusted, unique (by string value) values there exist for this variable.
-
ConfigDeclaration const *get_reference(std::size_t n) const
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.
-
int get_trust_level(void) const
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).
-
ConfigDeclaration const *get_trusted_reference(std::size_t n) const
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.
-
ConfigDeclaration const *get_unique_reference(std::size_t n) const
Returns the nth trusted, unique value for this variable. This is similar to
get_trusted_reference()
, except that duplicate values are removed.
-
ConfigFlags::ValueType get_value_type(void) const
Returns the stated type of this variable. If the variable has not yet been defined, this will be VT_undefined.
-
bool has_local_value(void) const
Returns true if this variable’s value has been shadowed by a local assignment (as created via
make_local_value()
), or false otherwise.
-
bool has_value(void) 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.
-
bool is_closed(void) const
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).
-
bool is_dynamic(void) const
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.
-
bool is_used(void) const
Returns true if the variable has been referenced by a
ConfigVariable
somewhere in code, false otherwise.
-
ConfigDeclaration *make_local_value(void)
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.
-
void output(std::ostream &out) const
-
void set_default_value(std::string const &default_value)
Specifies the default value for this variable if it is not defined in any prc file.
-
void set_description(std::string const &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 onceget_declaration()
has been called, a warning is printed.
-
void 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 onceget_declaration()
has been called, a warning is printed.
-
void set_used(void)
Marks that the variable has been “declared” by a
ConfigVariable
.
-
void set_value_type(ConfigFlags::ValueType 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 onceget_declaration()
has been called, a warning is printed.
-
void write(std::ostream &out) const
-
bool clear_local_value(void)