Panda3D
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
ConfigVariableManager Class Reference

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

size_t get_num_variables () const
 
ConfigVariableCoreget_variable (size_t n) const
 
std::string get_variable_name (size_t n) const
 Returns the name of the nth active ConfigVariable in the list. More...
 
bool is_variable_used (size_t n) const
 Returns true if the nth active ConfigVariable in the list has been used by code, false otherwise. More...
 
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. More...
 
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. More...
 
void list_variables () const
 Writes a list of all the variables that have been declared somewhere in code, along with a brief description. More...
 
ConfigVariableCoremake_variable (const std::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. More...
 
ConfigVariableCoremake_variable_template (const std::string &pattern, ConfigFlags::ValueType type, const std::string &default_value, const std::string &description=std::string(), int flags=0)
 Defines a variable "template" to match against dynamically-defined variables that may or may not be created in the future. More...
 
void output (std::ostream &out) const
 
void write (std::ostream &out) const
 
void write_prc_variables (std::ostream &out) const
 Writes all of the prc-set config variables, as they appear in a prc file somewhere, one per line, very concisely. More...
 

Static Public Member Functions

static ConfigVariableManagerget_global_ptr ()
 

Public Attributes

 get_num_variables
 Returns the current number of active ConfigVariableCores in the world. More...
 
 get_variable
 Returns the nth active ConfigVariableCore in the world. More...
 

Detailed Description

A global object that maintains the set of ConfigVariables (actually, ConfigVariableCores) everywhere in the world, and keeps them in sorted order.

Definition at line 31 of file configVariableManager.h.

Member Function Documentation

◆ get_variable_name()

string ConfigVariableManager::get_variable_name ( size_t  n) const

Returns the name of the nth active ConfigVariable in the list.

Definition at line 162 of file configVariableManager.cxx.

◆ is_variable_used()

bool ConfigVariableManager::is_variable_used ( size_t  n) const

Returns true if the nth active ConfigVariable in the list has been used by code, false otherwise.

Definition at line 174 of file configVariableManager.cxx.

◆ list_dynamic_variables()

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 288 of file configVariableManager.cxx.

References ConfigVariableCore::is_dynamic, and ConfigVariableCore::is_used.

◆ list_unused_variables()

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 247 of file configVariableManager.cxx.

References ConfigVariableCore::is_used.

◆ list_variables()

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 269 of file configVariableManager.cxx.

References ConfigVariableCore::is_dynamic, and ConfigVariableCore::is_used.

◆ make_variable()

ConfigVariableCore * ConfigVariableManager::make_variable ( const std::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 50 of file configVariableManager.cxx.

References GlobPattern::matches().

Referenced by ConfigPage::make_declaration().

◆ make_variable_template()

ConfigVariableCore * ConfigVariableManager::make_variable_template ( const std::string &  pattern,
ConfigFlags::ValueType  value_type,
const std::string &  default_value,
const std::string &  description = std::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 101 of file configVariableManager.cxx.

References ConfigVariableCore::get_default_value, ConfigVariableCore::set_default_value, ConfigVariableCore::set_description, ConfigVariableCore::set_flags(), ConfigVariableCore::set_used(), and ConfigVariableCore::set_value_type.

Referenced by init_libegg2pg().

◆ write_prc_variables()

void ConfigVariableManager::write_prc_variables ( std::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 216 of file configVariableManager.cxx.

References ConfigVariableCore::get_num_trusted_references, and ConfigVariableCore::get_value_type.

Member Data Documentation

◆ get_num_variables

size_t ConfigVariableManager::get_num_variables
inline

Returns the current number of active ConfigVariableCores in the world.

Definition at line 47 of file configVariableManager.h.

◆ get_variable

ConfigVariableCore * ConfigVariableManager::get_variable
inline

Returns the nth active ConfigVariableCore in the world.

Definition at line 47 of file configVariableManager.h.


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