Panda3D
Public Member Functions | Public Attributes | Friends | List of all members
ConfigVariableCore Class Reference

The internal definition of a ConfigVariable. More...

#include "configVariableCore.h"

Inheritance diagram for ConfigVariableCore:
ConfigFlags

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 ConfigDeclarationget_declaration (size_t n) const
 
const ConfigDeclarationget_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 ConfigDeclarationget_reference (size_t n) const
 
int get_trust_level () const
 
const ConfigDeclarationget_trusted_reference (size_t n) const
 
const ConfigDeclarationget_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
 
ConfigDeclarationmake_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
}
 

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

Member Function Documentation

◆ clear_local_value()

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().

◆ get_flags()

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

◆ has_local_value()

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

Referenced by has_value().

◆ 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().

◆ make_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().

◆ set_flags()

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().

◆ set_used()

void ConfigVariableCore::set_used ( )
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().

Member Data Documentation

◆ get_declaration

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().

◆ get_default_value

const ConfigDeclaration * ConfigVariableCore::get_default_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().

◆ get_description

const std::string & ConfigVariableCore::get_description
inline

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

Definition at line 90 of file configVariableCore.h.

◆ get_name

const std::string & ConfigVariableCore::get_name
inline

Returns the name of the variable.

Definition at line 83 of file configVariableCore.h.

◆ get_num_declarations

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.

◆ get_num_references

size_t ConfigVariableCore::get_num_references
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.

◆ get_num_trusted_references

size_t ConfigVariableCore::get_num_trusted_references
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().

◆ get_num_unique_references

size_t ConfigVariableCore::get_num_unique_references
inline

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

Definition at line 77 of file configVariableCore.h.

◆ get_reference

const ConfigDeclaration * ConfigVariableCore::get_reference
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.

◆ get_trust_level

int ConfigVariableCore::get_trust_level
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.

◆ get_trusted_reference

const ConfigDeclaration * ConfigVariableCore::get_trusted_reference
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.

◆ get_unique_reference

const ConfigDeclaration * ConfigVariableCore::get_unique_reference
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.

◆ get_value_type

ConfigVariableCore::ValueType ConfigVariableCore::get_value_type
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().

◆ is_closed

bool ConfigVariableCore::is_closed
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().

◆ is_dynamic

bool ConfigVariableCore::is_dynamic
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().

◆ is_used

bool ConfigVariableCore::is_used
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().

◆ set_default_value

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().

◆ set_description

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().

◆ set_value_type

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().


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