Panda3D
|
A global object that maintains the set of ConfigVariables (actually, ConfigVariableCores) everywhere in the world, and keeps them in sorted order. More...
#include "configVariableManager.h"
Public Member Functions | |
int | get_num_variables () const |
Returns the current number of active ConfigVariableCores in the world. | |
ConfigVariableCore * | get_variable (int n) const |
Returns the nth active ConfigVariableCore in the world. | |
string | get_variable_name (int n) const |
Returns the name of the nth active ConfigVariable in the list. | |
bool | is_variable_used (int n) const |
Returns true if the nth active ConfigVariable in the list has been used by code, false otherwise. | |
void | list_dynamic_variables () const |
Writes a list of all the "dynamic" variables that have been declared somewhere in code, along with a brief description. | |
void | list_unused_variables () const |
Writes a list of all the variables that have been defined in a prc file without having been declared somewhere in code. | |
void | list_variables () const |
Writes a list of all the variables that have been declared somewhere in code, along with a brief description. | |
ConfigVariableCore * | make_variable (const string &name) |
Creates and returns a new, undefined ConfigVariableCore with the indicated name; or if a variable with this name has already been created, returns that one instead. | |
ConfigVariableCore * | make_variable_template (const string &pattern, ConfigFlags::ValueType type, const string &default_value, const string &description=string(), int flags=0) |
Defines a variable "template" to match against dynamically-defined variables that may or may not be created in the future. | |
void | output (ostream &out) const |
void | write (ostream &out) const |
void | write_prc_variables (ostream &out) const |
Writes all of the prc-set config variables, as they appear in a prc file somewhere, one per line, very concisely. | |
Static Public Member Functions | |
static ConfigVariableManager * | get_global_ptr () |
Protected Member Functions | |
ConfigVariableManager () | |
The constructor is private (actually, just protected, but only to avoid a gcc compiler warning) because it should not be explicitly constructed. | |
~ConfigVariableManager () | |
The ConfigVariableManager destructor should never be called, because this is a global object that is never freed. |
A global object that maintains the set of ConfigVariables (actually, ConfigVariableCores) everywhere in the world, and keeps them in sorted order.
Definition at line 34 of file configVariableManager.h.
ConfigVariableManager::ConfigVariableManager | ( | ) | [protected] |
The constructor is private (actually, just protected, but only to avoid a gcc compiler warning) because it should not be explicitly constructed.
There is only one ConfigVariableManager, and it constructs itself.
Definition at line 33 of file configVariableManager.cxx.
ConfigVariableManager::~ConfigVariableManager | ( | ) | [protected] |
The ConfigVariableManager destructor should never be called, because this is a global object that is never freed.
Definition at line 45 of file configVariableManager.cxx.
int ConfigVariableManager::get_num_variables | ( | ) | const [inline] |
Returns the current number of active ConfigVariableCores in the world.
Definition at line 23 of file configVariableManager.I.
ConfigVariableCore * ConfigVariableManager::get_variable | ( | int | n | ) | const [inline] |
Returns the nth active ConfigVariableCore in the world.
Definition at line 33 of file configVariableManager.I.
string ConfigVariableManager::get_variable_name | ( | int | n | ) | const |
Returns the name of the nth active ConfigVariable in the list.
Definition at line 181 of file configVariableManager.cxx.
bool ConfigVariableManager::is_variable_used | ( | int | n | ) | const |
Returns true if the nth active ConfigVariable in the list has been used by code, false otherwise.
Definition at line 195 of file configVariableManager.cxx.
void ConfigVariableManager::list_dynamic_variables | ( | ) | const |
Writes a list of all the "dynamic" variables that have been declared somewhere in code, along with a brief description.
This is a (usually large) list of config variables that are declared with a generated variable name.
Definition at line 325 of file configVariableManager.cxx.
References ConfigVariableCore::is_dynamic(), and ConfigVariableCore::is_used().
void ConfigVariableManager::list_unused_variables | ( | ) | const |
Writes a list of all the variables that have been defined in a prc file without having been declared somewhere in code.
Definition at line 278 of file configVariableManager.cxx.
References ConfigPage::get_name(), ConfigVariableCore::get_name(), ConfigVariableCore::get_num_references(), ConfigDeclaration::get_page(), ConfigVariableCore::get_reference(), and ConfigVariableCore::is_used().
void ConfigVariableManager::list_variables | ( | ) | const |
Writes a list of all the variables that have been declared somewhere in code, along with a brief description.
Definition at line 303 of file configVariableManager.cxx.
References ConfigVariableCore::is_dynamic(), and ConfigVariableCore::is_used().
ConfigVariableCore * ConfigVariableManager::make_variable | ( | const string & | name | ) |
Creates and returns a new, undefined ConfigVariableCore with the indicated name; or if a variable with this name has already been created, returns that one instead.
Definition at line 59 of file configVariableManager.cxx.
References GlobPattern::matches().
Referenced by ConfigPage::make_declaration().
ConfigVariableCore * ConfigVariableManager::make_variable_template | ( | const string & | pattern, |
ConfigFlags::ValueType | value_type, | ||
const string & | default_value, | ||
const string & | description = string() , |
||
int | flags = 0 |
||
) |
Defines a variable "template" to match against dynamically-defined variables that may or may not be created in the future.
The template consists of a glob pattern, e.g. "notify-level-*", which will be tested against any config variable passed to a future call to make_variable(). If the pattern matches, the returned ConfigVariableCore is copied to define the new variable, instead of creating a default, empty one.
This is useful to pre-specify default values for a family of variables that all have similar properties, and all may not be created at the same time. It is especially useful to avoid cluttering up the list of available variables with user-declared variables that have not been defined yet by the application (e.g. "egg-object-type-*").
This method basically pre-defines all variables that match the specified glob pattern.
Definition at line 117 of file configVariableManager.cxx.
References ConfigVariableCore::get_default_value(), ConfigVariableCore::get_name(), GlobPattern::matches(), ConfigVariableCore::set_default_value(), ConfigVariableCore::set_description(), ConfigVariableCore::set_flags(), ConfigVariableCore::set_used(), and ConfigVariableCore::set_value_type().
void ConfigVariableManager::write_prc_variables | ( | ostream & | out | ) | const |
Writes all of the prc-set config variables, as they appear in a prc file somewhere, one per line, very concisely.
This lists the dominant value in the prc file; it does not list shadowed values, and it does not list locally-set values.
This is mainly intended for generating a hash of the input config file state.
Definition at line 244 of file configVariableManager.cxx.
References ConfigVariableCore::get_name(), ConfigVariableCore::get_num_trusted_references(), ConfigDeclaration::get_string_value(), ConfigVariableCore::get_trusted_reference(), and ConfigVariableCore::get_value_type().