ConfigVariableCore

from panda3d.core import ConfigVariableCore
class ConfigVariableCore

Bases:

Bases: ConfigFlags, MemoryBase

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

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

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

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.

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

get_declarations() list
get_default_value() ConfigDeclaration

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

get_description() str

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

get_flags() int

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.

get_name() str

Returns the name of the variable.

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

get_num_references() int

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

get_num_trusted_references() int

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

get_num_unique_references() int

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

get_reference(n: int) ConfigDeclaration

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.

get_references() list
get_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 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).

get_trusted_reference(n: int) ConfigDeclaration

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.

get_trusted_references() list
get_unique_reference(n: int) ConfigDeclaration

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

get_unique_references() list
get_value_type() ValueType

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

has_local_value() bool

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

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

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

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

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

is_used() bool

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

make_local_value() 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 clear_local_value() 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, 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.

set_default_value(default_value: str)

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

set_description(description: str)

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.

set_flags(flags: int)

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.

set_used()

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

set_value_type(value_type: ValueType)

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.

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

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

property unique_references Sequence[ConfigDeclaration]

Returns the nth trusted, unique value for this variable. This is similar to get_trusted_reference(), 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 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(out: ostream)