Panda3D
Public Member Functions | Friends
ConfigVariableCore Class Reference

The internal definition of a ConfigVariable. More...

#include "configVariableCore.h"

Inheritance diagram for ConfigVariableCore:
ConfigFlags

List of all members.

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.
const ConfigDeclarationget_declaration (int n) const
 Returns the nth declarations that contributes to this variable's value.
const ConfigDeclarationget_default_value () const
 Returns the default variable specified for this variable.
const string & get_description () const
 Returns the brief description of this variable, if it has been defined.
int get_flags () const
 Returns the flags value as set by set_flags().
const string & get_name () const
 Returns the name of the variable.
int get_num_declarations () const
 Returns the number of declarations that contribute to this variable's value.
int get_num_references () const
 Returns the number of prc files that reference this variable.
int get_num_trusted_references () const
 Returns the number of trusted prc files that reference this variable.
int get_num_unique_references () const
 Returns the number of trusted, unique (by string value) values there exist for this variable.
const ConfigDeclarationget_reference (int n) const
 Returns the nth declaration in a prc file that references this variable.
int get_trust_level () const
 Returns the minimum trust_level a prc file must demonstrate in order to redefine the value for this variable.
const ConfigDeclarationget_trusted_reference (int n) const
 Returns the nth declaration in a trusted prc file that references this variable.
const ConfigDeclarationget_unique_reference (int n) const
 Returns the nth trusted, unique value for this variable.
ValueType get_value_type () const
 Returns the stated type of this variable.
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.
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.
bool is_closed () 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()).
bool is_dynamic () 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 () const
 Returns true if the variable has been referenced by a ConfigVariable somewhere in code, false otherwise.
ConfigDeclarationmake_local_value ()
 Creates a new local value for this variable, if there is not already one specified.
void output (ostream &out) const
void set_default_value (const string &default_value)
 Specifies the default value for this variable if it is not defined in any prc file.
void set_description (const string &description)
 Specifies the one-line description of this variable.
void set_flags (int flags)
 Specifies the trust level of this variable.
void set_used ()
 Marks that the variable has been "declared" by a ConfigVariable.
void set_value_type (ValueType value_type)
 Specifies the type of this variable.
void write (ostream &out) const

Friends

class ConfigDeclaration
class ConfigVariableManager

Detailed Description

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 38 of file configVariableCore.h.


Member Function Documentation

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 286 of file configVariableCore.cxx.

References ConfigPage::delete_declaration(), ConfigPage::get_local_page(), and ConfigFlags::invalidate_cache().

Referenced by ConfigVariableSearchPath::clear_local_value(), ConfigVariableBase::clear_local_value(), and ConfigVariable::clear_value().

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 346 of file configVariableCore.cxx.

References get_name(), and has_local_value().

Referenced by ConfigVariable::get_bool_word(), ConfigVariable::get_double_word(), ConfigVariable::get_int64_word(), ConfigVariable::get_int_word(), ConfigVariable::get_num_words(), ConfigVariable::get_string_value(), ConfigVariable::get_string_word(), ConfigVariable::has_bool_word(), ConfigVariable::has_double_word(), ConfigVariable::has_int64_word(), ConfigVariable::has_int_word(), ConfigVariable::has_string_word(), and make_local_value().

Returns the default variable specified for this variable.

If the variable has not yet been defined, this will return NULL.

Definition at line 135 of file configVariableCore.I.

Referenced by ConfigVariable::get_default_value(), and ConfigVariableManager::make_variable_template().

const string & ConfigVariableCore::get_description ( ) const [inline]

Returns the brief description of this variable, if it has been defined.

Definition at line 56 of file configVariableCore.I.

Referenced by ConfigVariableBase::get_description().

int ConfigVariableCore::get_flags ( ) const [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 70 of file configVariableCore.I.

Referenced by ConfigVariableBase::get_flags().

const string & ConfigVariableCore::get_name ( ) const [inline]

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 322 of file configVariableCore.cxx.

References has_local_value().

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 170 of file configVariableCore.I.

Referenced by ConfigVariableManager::list_unused_variables().

Returns the number of trusted prc files that reference this variable.

See also get_num_references().

Definition at line 201 of file configVariableCore.I.

Referenced by ConfigVariableList::get_num_values(), and ConfigVariableManager::write_prc_variables().

Returns the number of trusted, unique (by string value) values there exist for this variable.

Definition at line 234 of file configVariableCore.I.

Referenced by ConfigVariableList::get_num_unique_values().

const ConfigDeclaration * ConfigVariableCore::get_reference ( int  n) const [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 187 of file configVariableCore.I.

Referenced by ConfigVariableManager::list_unused_variables().

int ConfigVariableCore::get_trust_level ( ) const [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 109 of file configVariableCore.I.

Referenced by ConfigVariableBase::get_trust_level().

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 221 of file configVariableCore.I.

Referenced by ConfigVariableList::get_string_value(), and ConfigVariableManager::write_prc_variables().

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 248 of file configVariableCore.I.

Referenced by ConfigVariableList::get_unique_value().

ConfigVariableCore::ValueType ConfigVariableCore::get_value_type ( ) const [inline]

Returns the stated type of this variable.

If the variable has not yet been defined, this will be VT_undefined.

Definition at line 45 of file configVariableCore.I.

Referenced by ConfigVariableBase::get_value_type(), and ConfigVariableManager::write_prc_variables().

bool ConfigVariableCore::has_local_value ( ) const [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 158 of file configVariableCore.I.

Referenced by get_declaration(), get_num_declarations(), ConfigVariableBase::has_local_value(), and has_value().

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 305 of file configVariableCore.cxx.

References has_local_value().

Referenced by ConfigVariableBase::has_value().

bool ConfigVariableCore::is_closed ( ) const [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 89 of file configVariableCore.I.

Referenced by ConfigVariableBase::is_closed(), and make_local_value().

bool ConfigVariableCore::is_dynamic ( ) const [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 123 of file configVariableCore.I.

Referenced by ConfigVariableBase::is_dynamic(), ConfigVariableManager::list_dynamic_variables(), and ConfigVariableManager::list_variables().

bool ConfigVariableCore::is_used ( ) const [inline]

Returns true if the variable has been referenced by a ConfigVariable somewhere in code, false otherwise.

Definition at line 33 of file configVariableCore.I.

Referenced by ConfigVariableManager::list_dynamic_variables(), ConfigVariableManager::list_unused_variables(), and ConfigVariableManager::list_variables().

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 258 of file configVariableCore.cxx.

References get_declaration(), ConfigPage::get_local_page(), ConfigDeclaration::get_string_value(), is_closed(), and ConfigPage::make_declaration().

Referenced by ConfigVariable::set_bool_word(), ConfigVariable::set_double_word(), ConfigVariable::set_int64_word(), ConfigVariable::set_int_word(), ConfigVariable::set_string_value(), and ConfigVariable::set_string_word().

void ConfigVariableCore::set_default_value ( const string &  default_value)

Specifies the default value for this variable if it is not defined in any prc file.

Definition at line 211 of file configVariableCore.cxx.

References ConfigPage::get_default_page(), get_name(), ConfigDeclaration::get_string_value(), ConfigPage::make_declaration(), and ConfigDeclaration::set_string_value().

Referenced by ConfigVariableManager::make_variable_template().

void ConfigVariableCore::set_description ( const string &  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 167 of file configVariableCore.cxx.

References get_name().

Referenced by ConfigVariableBase::ConfigVariableBase(), and ConfigVariableManager::make_variable_template().

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 125 of file configVariableCore.cxx.

References get_name().

Referenced by ConfigVariableBase::ConfigVariableBase(), and ConfigVariableManager::make_variable_template().

void ConfigVariableCore::set_used ( ) [inline]

Marks that the variable has been "declared" by a ConfigVariable.

Definition at line 146 of file configVariableCore.I.

Referenced by ConfigVariable::ConfigVariable(), and ConfigVariableManager::make_variable_template().

void ConfigVariableCore::set_value_type ( 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 once get_declaration() has been called, a warning is printed.

Definition at line 96 of file configVariableCore.cxx.

References get_name().

Referenced by ConfigVariableBase::ConfigVariableBase(), and ConfigVariableManager::make_variable_template().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations