# panda3d.core.ConfigVariableCore¶

class ConfigVariableCore

Bases: ConfigFlags

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.

Inheritance diagram

clearLocalValue() → bool

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.

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

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

Return type

bool

property declarations

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.

Return type
property default_value
Getter

Returns the default variable specified for this variable. If the variable has not yet been defined, this will return NULL.

Setter

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

Return type

ConfigDeclaration

property description
Getter

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

Setter

Specifies the one-line description of this variable. See getDescription(). It is not an error to call this multiple times, but if the value changes once getDeclaration() has been called, a warning is printed.

Return type

string

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

Return type

bool

getDeclaration(n: size_t) → ConfigDeclaration

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.

Return type

ConfigDeclaration

getDeclarations() → list
getDefaultValue() → ConfigDeclaration

Returns the default variable specified for this variable. If the variable has not yet been defined, this will return NULL.

Return type

ConfigDeclaration

getDescription() → str

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

getFlags() → int

Returns the flags value as set by setFlags(). This includes the trust level and some other settings. See the individual methods isClosed(), getTrustLevel(), etc. to pull out the semantic meaning of these flags individually.

getName() → str

Returns the name of the variable.

getNumDeclarations() → size_t

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

Return type

size_t

getNumReferences() → size_t

Returns the number of prc files that reference this variable. This is not exactly the same as the number of declarations; see getReference().

Return type

size_t

getNumTrustedReferences() → size_t

Returns the number of trusted prc files that reference this variable. See also getNumReferences().

Return type

size_t

getNumUniqueReferences() → size_t

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

Return type

size_t

getReference(n: size_t) → ConfigDeclaration

Returns the nth declaration in a prc file that references this variable. This is similar, but not identical to, getDeclaration(). 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.

Return type

ConfigDeclaration

getReferences() → list
getTrustLevel() → int

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

getTrustedReference(n: size_t) → ConfigDeclaration

Returns the nth declaration in a trusted prc file that references this variable. This is similar, but not identical to, getDeclaration(). 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 getReference(), except that it only lists the trusted declarations, omitting the untrusted ones.

Return type

ConfigDeclaration

getTrustedReferences() → list
getUniqueReference(n: size_t) → ConfigDeclaration

Returns the nth trusted, unique value for this variable. This is similar to getTrustedReference(), except that duplicate values are removed.

Return type

ConfigDeclaration

getUniqueReferences() → list
getValueType() → ValueType

Returns the stated type of this variable. If the variable has not yet been defined, this will be VT_undefined.

Return type

ValueType

hasLocalValue() → bool

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

hasValue() → bool

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

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

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

isDynamic() → bool

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

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

makeLocalValue() → ConfigDeclaration

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 clearLocalValue() to remove the local value definition.

Return type

ConfigDeclaration

property name

Returns the name of the variable.

Return type

string

output(out: ostream) → None
property references

Returns the nth declaration in a prc file that references this variable. This is similar, but not identical to, getDeclaration(). 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.

Return type
setDefaultValue(default_value: str) → None

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

setDescription(description: str) → None

Specifies the one-line description of this variable. See getDescription(). It is not an error to call this multiple times, but if the value changes once getDeclaration() has been called, a warning is printed.

setFlags(flags: int) → None

Specifies the trust level of this variable. See getFlags(). It is not an error to call this multiple times, but if the value changes once getDeclaration() has been called, a warning is printed.

setUsed() → None

Marks that the variable has been “declared” by a ConfigVariable.

setValueType(value_type: ValueType) → None

Specifies the type of this variable. See getValueType(). It is not an error to call this multiple times, but if the value changes once getDeclaration() has been called, a warning is printed.

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

Return type

int

property trusted_references

Returns the nth declaration in a trusted prc file that references this variable. This is similar, but not identical to, getDeclaration(). 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 getReference(), except that it only lists the trusted declarations, omitting the untrusted ones.

Return type
property unique_references

Returns the nth trusted, unique value for this variable. This is similar to getTrustedReference(), except that duplicate values are removed.

Return type
property used

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

Return type

bool

property value_type
Getter

Returns the stated type of this variable. If the variable has not yet been defined, this will be VT_undefined.

Setter

Specifies the type of this variable. See getValueType(). It is not an error to call this multiple times, but if the value changes once getDeclaration() has been called, a warning is printed.

Return type

ValueType

write(out: ostream) → None