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

The internal definition of a ConfigVariable. More...

Inheritance diagram for ConfigVariableCore:
ConfigFlags

Public Member Functions

bool clearLocalValue ()
 Removes the local value defined for this variable, and allows its value to be once again retrieved from the .prc files. More...
 
const ConfigDeclaration getDeclaration (int n)
 Returns the nth declarations that contributes to this variable's value. More...
 
list getDeclarations ()
 
const ConfigDeclaration getDefaultValue ()
 Returns the default variable specified for this variable. More...
 
str getDescription ()
 Returns the brief description of this variable, if it has been defined. More...
 
int getFlags ()
 Returns the flags value as set by set_flags(). More...
 
str getName ()
 Returns the name of the variable. More...
 
int getNumDeclarations ()
 Returns the number of declarations that contribute to this variable's value. More...
 
int getNumReferences ()
 Returns the number of prc files that reference this variable. More...
 
int getNumTrustedReferences ()
 Returns the number of trusted prc files that reference this variable. More...
 
int getNumUniqueReferences ()
 Returns the number of trusted, unique (by string value) values there exist for this variable. More...
 
const ConfigDeclaration getReference (int n)
 Returns the nth declaration in a prc file that references this variable. More...
 
list getReferences ()
 
const ConfigDeclaration getTrustedReference (int n)
 Returns the nth declaration in a trusted prc file that references this variable. More...
 
list getTrustedReferences ()
 
int getTrustLevel ()
 Returns the minimum trust_level a prc file must demonstrate in order to redefine the value for this variable. More...
 
const ConfigDeclaration getUniqueReference (int n)
 Returns the nth trusted, unique value for this variable. More...
 
list getUniqueReferences ()
 
ConfigFlags::ValueType getValueType ()
 Returns the stated type of this variable. More...
 
bool hasLocalValue ()
 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 hasValue ()
 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 isClosed ()
 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...
 
bool isDynamic ()
 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...
 
bool isUsed ()
 Returns true if the variable has been referenced by a ConfigVariable somewhere in code, false otherwise. More...
 
ConfigDeclaration makeLocalValue ()
 Creates a new local value for this variable, if there is not already one specified. More...
 
 output (Ostream out)
 
 setDefaultValue (str default_value)
 Specifies the default value for this variable if it is not defined in any prc file. More...
 
 setDescription (str description)
 Specifies the one-line description of this variable. More...
 
 setFlags (int flags)
 Specifies the trust level of this variable. More...
 
 setUsed ()
 Marks that the variable has been "declared" by a ConfigVariable. More...
 
 setValueType (ConfigFlags::ValueType value_type)
 Specifies the type of this variable. More...
 
 write (Ostream out)
 
- Public Member Functions inherited from ConfigFlags
 __init__ ()
 
 __init__ (const ConfigFlags)
 

Public Attributes

bool 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...
 
const ConfigDeclaration declarations []
 
const ConfigDeclaration default_value
 Returns the default variable specified for this variable. More...
 
const String description
 Returns the brief description of this variable, if it has been defined. More...
 
bool 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...
 
const String name
 Returns the name of the variable. More...
 
const ConfigDeclaration references []
 
int trust_level
 Returns the minimum trust_level a prc file must demonstrate in order to redefine the value for this variable. More...
 
const ConfigDeclaration trusted_references []
 
const ConfigDeclaration unique_references []
 
bool used
 Returns true if the variable has been referenced by a ConfigVariable somewhere in code, false otherwise. More...
 
ConfigFlags::ValueType value_type
 Returns the stated type of this variable. More...
 

Additional Inherited Members

- Public Types inherited from ConfigFlags
enum  ValueType {
  VT_undefined = 0, VT_list = 1, VT_string = 2, VT_filename = 3,
  VT_bool = 4, VT_int = 5, VT_double = 6, VT_enum = 7,
  VT_search_path = 8, VT_int64 = 9, VT_color = 10
}
 
enum  VariableFlags {
  F_trust_level_mask = 4095, F_open = 4096, F_closed = 8192, F_dynamic = 16384,
  F_dconfig = 32768
}
 

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.

Member Function Documentation

◆ clearLocalValue()

bool clearLocalValue ( )

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.

◆ getDeclaration()

const ConfigDeclaration getDeclaration ( int  n)

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.

◆ getDeclarations()

list getDeclarations ( )

◆ getDefaultValue()

const ConfigDeclaration getDefaultValue ( )

Returns the default variable specified for this variable.

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

◆ getDescription()

str getDescription ( )

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

◆ getFlags()

int getFlags ( )

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.

◆ getName()

str getName ( )

Returns the name of the variable.

◆ getNumDeclarations()

int getNumDeclarations ( )

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

◆ getNumReferences()

int getNumReferences ( )

Returns the number of prc files that reference this variable.

This is not exactly the same as the number of declarations; see get_reference().

◆ getNumTrustedReferences()

int getNumTrustedReferences ( )

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

See also get_num_references().

◆ getNumUniqueReferences()

int getNumUniqueReferences ( )

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

◆ getReference()

const ConfigDeclaration getReference ( int  n)

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.

◆ getReferences()

list getReferences ( )

◆ getTrustedReference()

const ConfigDeclaration getTrustedReference ( int  n)

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.

◆ getTrustedReferences()

list getTrustedReferences ( )

◆ getTrustLevel()

int getTrustLevel ( )

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

◆ getUniqueReference()

const ConfigDeclaration getUniqueReference ( int  n)

Returns the nth trusted, unique value for this variable.

This is similar to get_trusted_reference(), except that duplicate values are removed.

◆ getUniqueReferences()

list getUniqueReferences ( )

◆ getValueType()

ConfigFlags::ValueType getValueType ( )

Returns the stated type of this variable.

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

◆ hasLocalValue()

bool hasLocalValue ( )

Returns true if this variable's value has been shadowed by a local assignment (as created via make_local_value()), or false otherwise.

◆ hasValue()

bool hasValue ( )

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.

◆ isClosed()

bool isClosed ( )

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

◆ isDynamic()

bool isDynamic ( )

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.

◆ isUsed()

bool isUsed ( )

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

◆ makeLocalValue()

ConfigDeclaration makeLocalValue ( )

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.

◆ output()

output ( Ostream  out)

◆ setDefaultValue()

setDefaultValue ( str  default_value)

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

◆ setDescription()

setDescription ( str  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.

◆ setFlags()

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

◆ setUsed()

setUsed ( )

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

◆ setValueType()

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

◆ write()

write ( Ostream  out)

Member Data Documentation

◆ closed

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

This value only has effect in a release build (specifically, when PRC_RESPECT_TRUST_LEVEL is defined true in Config.pp).

◆ declarations

const ConfigDeclaration declarations[]

◆ default_value

const ConfigDeclaration default_value

Returns the default variable specified for this variable.

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

◆ description

const String description

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

◆ dynamic

bool 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.

◆ name

const String name

Returns the name of the variable.

◆ references

const ConfigDeclaration references[]

◆ trust_level

int trust_level

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

◆ trusted_references

const ConfigDeclaration trusted_references[]

◆ unique_references

const ConfigDeclaration unique_references[]

◆ used

bool used

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

◆ value_type

Returns the stated type of this variable.

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