ConfigVariableCore

from panda3d.core import ConfigVariableCore
class ConfigVariableCore

Bases:

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

Inheritance diagram of ConfigVariableCore

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

property declarations Sequence[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.

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

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

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

getDeclaration(n: int) 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.

getDeclarations() list
getDefaultValue() ConfigDeclaration

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

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

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

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

getNumTrustedReferences() int

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

getNumUniqueReferences() int

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

getReference(n: int) 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.

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

getTrustedReferences() list
getUniqueReference(n: int) ConfigDeclaration

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

getUniqueReferences() list
getValueType() ValueType

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

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.

property name string

Returns the name of the variable.

output(out: ostream)
property references Sequence[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.

setDefaultValue(default_value: str)

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

setDescription(description: str)

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)

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

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

setValueType(value_type: ValueType)

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

property trusted_references Sequence[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.

property unique_references Sequence[ConfigDeclaration]

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

property used bool

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

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

write(out: ostream)