Panda3D
|
This is a convenience class to specialize ConfigVariable as a floating-point type. More...
#include "configVariableDouble.h"
Public Types | |
enum | ValueType { VT_undefined, VT_list, VT_string, VT_filename, VT_bool, VT_int, VT_double, VT_enum, VT_search_path, VT_int64 } |
enum | VariableFlags { F_trust_level_mask = 0x00000fff, F_open = 0x00001000, F_closed = 0x00002000, F_dynamic = 0x00004000, F_dconfig = 0x00008000 } |
Public Member Functions | |
ConfigVariableDouble (const string &name) | |
ConfigVariableDouble (const string &name, double default_value, const string &description=string(), int flags=0) | |
ConfigVariableDouble (const string &name, const string &default_value, const string &description=string(), int flags=0) | |
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. | |
void | clear_value () |
Removes the value assigned to this variable, and lets its original value (as read from the prc files) show through. | |
bool | get_bool_word (int n) const |
Returns the boolean value of the nth word of the variable's value, or false if there is no nth value. | |
double | get_default_value () const |
Returns the variable's default value. | |
const string & | get_description () const |
Returns the brief description of this variable, if it has been defined. | |
double | get_double_word (int n) const |
Returns the integer value of the nth word of the variable's value, or 0 if there is no nth value. | |
int | get_flags () const |
Returns the flags value as set by set_flags(). | |
PN_int64 | get_int64_word (int n) const |
Returns the int64 value of the nth word of the variable's value, or 0 if there is no nth value. | |
int | get_int_word (int n) const |
Returns the integer value of the nth word of the variable's value, or 0 if there is no nth value. | |
const string & | get_name () const |
Returns the name of the variable. | |
int | get_num_words () const |
Returns the number of words in the variable's value. | |
const string & | get_string_value () const |
Returns the toplevel value of the variable, formatted as a string. | |
string | get_string_word (int n) const |
Returns the string value of the nth word of the variable's value, or empty string if there is no nth value. | |
int | get_trust_level () const |
Returns the minimum trust_level a prc file must demonstrate in order to redefine the value for this variable. | |
double | get_value () const |
Returns the variable's value. | |
ValueType | get_value_type () const |
Returns the stated type of this variable. | |
double | get_word (int n) const |
Returns the variable's nth value. | |
bool | has_bool_word (int n) const |
Returns true if the variable's value has a valid boolean value for the nth word. | |
bool | has_double_word (int n) const |
Returns true if the variable's value has a valid integer value for the nth word. | |
bool | has_int64_word (int n) const |
Returns true if the variable's value has a valid 64-bit integer value for the nth word. | |
bool | has_int_word (int n) const |
Returns true if the variable's value has a valid integer value for the nth word. | |
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. | |
bool | has_string_word (int n) const |
Returns true if the variable's value has a valid string value for the nth word. | |
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. | |
bool | is_closed () const |
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()). | |
bool | is_dynamic () const |
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. | |
operator double () const | |
Returns the variable's value. | |
void | operator= (double value) |
Reassigns the variable's local value. | |
double | operator[] (int n) const |
Returns the value of the variable's nth word. | |
void | output (ostream &out) const |
void | set_bool_word (int n, bool value) |
Changes the nth word to the indicated value without affecting the other words. | |
void | set_double_word (int n, double value) |
Changes the nth word to the indicated value without affecting the other words. | |
void | set_int64_word (int n, PN_int64 value) |
Changes the nth word to the indicated value without affecting the other words. | |
void | set_int_word (int n, int value) |
Changes the nth word to the indicated value without affecting the other words. | |
void | set_string_value (const string &value) |
Changes the value assigned to this variable. | |
void | set_string_word (int n, const string &value) |
Changes the nth word to the indicated value without affecting the other words. | |
void | set_value (double value) |
Reassigns the variable's local value. | |
void | set_word (int n, double value) |
Reassigns the variable's nth value. | |
int | size () const |
Returns the number of unique words in the variable. | |
void | write (ostream &out) const |
Protected Types | |
typedef pset< const ConfigVariableBase * > | Unconstructed |
Protected Member Functions | |
bool | is_constructed () const |
Returns true if the constructor has been called and _core initialized, false if the constructor has not yet been called and _core is NULL. | |
void | record_unconstructed () const |
Records that this config variable was referenced before it was constructed (presumably a static-init ordering issue). | |
void | report_unconstructed () const |
Displays a suitable error message when an unconstructed ConfigVariable is attempted to be used. | |
bool | was_unconstructed () const |
Returns true if record_unconstructed() was ever called on this pointer, false otherwise. | |
Static Protected Member Functions | |
static AtomicAdjust::Integer | initial_invalid_cache () |
Returns a value that will be appropriate for initializing a local_modified value. | |
static void | invalidate_cache () |
Invalidates all of the global ConfigVariable caches in the world at once, by incrementing the global_modified counter. | |
static bool | is_cache_valid (AtomicAdjust::Integer local_modified) |
Returns true if the local object's cache is still valid (based on a comparison of the supplied local_modified value with the global_modified value). | |
static void | mark_cache_valid (AtomicAdjust::Integer &local_modified) |
Updates the indicated local_modified value so that the cache will appear to be valid, until someone next calls invalidate_cache(). | |
Protected Attributes | |
ConfigVariableCore * | _core |
Static Protected Attributes | |
static Unconstructed * | _unconstructed |
This is a convenience class to specialize ConfigVariable as a floating-point type.
Definition at line 26 of file configVariableDouble.h.
bool ConfigVariableBase::clear_local_value | ( | ) | [inline, inherited] |
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.
Reimplemented in ConfigVariableSearchPath.
Definition at line 159 of file configVariableBase.I.
References ConfigVariableCore::clear_local_value().
void ConfigVariable::clear_value | ( | ) | [inline, inherited] |
Removes the value assigned to this variable, and lets its original value (as read from the prc files) show through.
Definition at line 113 of file configVariable.I.
References ConfigVariableCore::clear_local_value(), and ConfigVariable::is_constructed().
bool ConfigVariable::get_bool_word | ( | int | n | ) | const [inline, inherited] |
Returns the boolean value of the nth word of the variable's value, or false if there is no nth value.
See also has_bool_word().
Definition at line 221 of file configVariable.I.
References ConfigDeclaration::get_bool_word(), ConfigVariableCore::get_declaration(), and ConfigVariable::is_constructed().
Referenced by ConfigVariableBool::get_value(), and ConfigVariableBool::get_word().
double ConfigVariableDouble::get_default_value | ( | ) | const [inline] |
Returns the variable's default value.
Reimplemented from ConfigVariable.
Definition at line 139 of file configVariableDouble.I.
References ConfigDeclaration::get_double_word().
const string & ConfigVariableBase::get_description | ( | ) | const [inline, inherited] |
Returns the brief description of this variable, if it has been defined.
Definition at line 72 of file configVariableBase.I.
References ConfigVariableCore::get_description().
double ConfigVariable::get_double_word | ( | int | n | ) | const [inline, inherited] |
Returns the integer value of the nth word of the variable's value, or 0 if there is no nth value.
See also has_double_word().
Definition at line 263 of file configVariable.I.
References ConfigVariableCore::get_declaration(), ConfigDeclaration::get_double_word(), and ConfigVariable::is_constructed().
Referenced by get_value(), and get_word().
int ConfigVariableBase::get_flags | ( | ) | const [inline, inherited] |
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 87 of file configVariableBase.I.
References ConfigVariableCore::get_flags().
PN_int64 ConfigVariable::get_int64_word | ( | int | n | ) | const [inline, inherited] |
Returns the int64 value of the nth word of the variable's value, or 0 if there is no nth value.
See also has_int_word().
Definition at line 249 of file configVariable.I.
References ConfigVariableCore::get_declaration(), ConfigDeclaration::get_int64_word(), and ConfigVariable::is_constructed().
Referenced by ConfigVariableInt64::get_value(), and ConfigVariableInt64::get_word().
int ConfigVariable::get_int_word | ( | int | n | ) | const [inline, inherited] |
Returns the integer value of the nth word of the variable's value, or 0 if there is no nth value.
See also has_int_word().
Definition at line 235 of file configVariable.I.
References ConfigVariableCore::get_declaration(), ConfigDeclaration::get_int_word(), and ConfigVariable::is_constructed().
Referenced by ConfigVariableInt::get_value(), and ConfigVariableInt::get_word().
const string & ConfigVariableBase::get_name | ( | ) | const [inline, inherited] |
Returns the name of the variable.
Definition at line 47 of file configVariableBase.I.
References ConfigVariableCore::get_name().
int ConfigVariable::get_num_words | ( | ) | const [inline, inherited] |
Returns the number of words in the variable's value.
A word is defined as a sequence of non-whitespace characters delimited by whitespace.
Definition at line 126 of file configVariable.I.
References ConfigVariableCore::get_declaration(), ConfigDeclaration::get_num_words(), and ConfigVariable::is_constructed().
Referenced by WindowProperties::get_config_properties(), FrameBufferProperties::get_default(), GraphicsOutput::GraphicsOutput(), ConfigVariableInt64::size(), ConfigVariableInt::size(), size(), and ConfigVariableBool::size().
const string & ConfigVariable::get_string_value | ( | ) | const [inline, inherited] |
Returns the toplevel value of the variable, formatted as a string.
Definition at line 85 of file configVariable.I.
References ConfigVariableCore::get_declaration(), ConfigDeclaration::get_string_value(), and ConfigVariable::is_constructed().
Referenced by ConfigVariableString::get_value(), and GraphicsOutput::GraphicsOutput().
string ConfigVariable::get_string_word | ( | int | n | ) | const [inline, inherited] |
Returns the string value of the nth word of the variable's value, or empty string if there is no nth value.
See also has_string_word().
Definition at line 207 of file configVariable.I.
References ConfigVariableCore::get_declaration(), ConfigDeclaration::get_string_word(), and ConfigVariable::is_constructed().
Referenced by ConfigVariableString::get_word(), and ConfigVariableFilename::get_word().
int ConfigVariableBase::get_trust_level | ( | ) | const [inline, inherited] |
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 128 of file configVariableBase.I.
References ConfigVariableCore::get_trust_level().
double ConfigVariableDouble::get_value | ( | ) | const [inline] |
Returns the variable's value.
Definition at line 124 of file configVariableDouble.I.
References ConfigVariable::get_double_word(), ConfigFlags::is_cache_valid(), and ConfigFlags::mark_cache_valid().
Referenced by operator double().
ConfigVariableBase::ValueType ConfigVariableBase::get_value_type | ( | ) | const [inline, inherited] |
Returns the stated type of this variable.
This should be VT_list, unless a later variable declaration has changed it.
Definition at line 60 of file configVariableBase.I.
References ConfigVariableCore::get_value_type().
double ConfigVariableDouble::get_word | ( | int | n | ) | const [inline] |
Returns the variable's nth value.
Definition at line 153 of file configVariableDouble.I.
References ConfigVariable::get_double_word().
Referenced by operator[]().
bool ConfigVariable::has_bool_word | ( | int | n | ) | const [inline, inherited] |
Returns true if the variable's value has a valid boolean value for the nth word.
Definition at line 154 of file configVariable.I.
References ConfigVariableCore::get_declaration(), ConfigDeclaration::has_bool_word(), and ConfigVariable::is_constructed().
bool ConfigVariable::has_double_word | ( | int | n | ) | const [inline, inherited] |
Returns true if the variable's value has a valid integer value for the nth word.
Definition at line 193 of file configVariable.I.
References ConfigVariableCore::get_declaration(), ConfigDeclaration::has_double_word(), and ConfigVariable::is_constructed().
bool ConfigVariable::has_int64_word | ( | int | n | ) | const [inline, inherited] |
Returns true if the variable's value has a valid 64-bit integer value for the nth word.
Definition at line 180 of file configVariable.I.
References ConfigVariableCore::get_declaration(), ConfigDeclaration::has_int64_word(), and ConfigVariable::is_constructed().
bool ConfigVariable::has_int_word | ( | int | n | ) | const [inline, inherited] |
Returns true if the variable's value has a valid integer value for the nth word.
Definition at line 167 of file configVariable.I.
References ConfigVariableCore::get_declaration(), ConfigDeclaration::has_int_word(), and ConfigVariable::is_constructed().
bool ConfigVariableBase::has_local_value | ( | ) | const [inline, inherited] |
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 172 of file configVariableBase.I.
References ConfigVariableCore::has_local_value().
bool ConfigVariable::has_string_word | ( | int | n | ) | const [inline, inherited] |
Returns true if the variable's value has a valid string value for the nth word.
This is really the same thing as asking if there are at least n words in the value.
Definition at line 141 of file configVariable.I.
References ConfigVariableCore::get_declaration(), ConfigDeclaration::has_string_word(), and ConfigVariable::is_constructed().
bool ConfigVariableBase::has_value | ( | ) | const [inline, inherited] |
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 185 of file configVariableBase.I.
References ConfigVariableCore::has_value().
Referenced by wglGraphicsStateGuardian::choose_pixel_format(), Lens::clear(), and GraphicsStateGuardian::get_copy_texture_inverted().
AtomicAdjust::Integer ConfigFlags::initial_invalid_cache | ( | ) | [inline, static, protected, inherited] |
Returns a value that will be appropriate for initializing a local_modified value.
This value will indicate an invalid cache in the next call to is_cache_valid().
Definition at line 49 of file configFlags.I.
Referenced by ConfigVariableSearchPath::append_directory(), ConfigVariableSearchPath::append_path(), ConfigVariableSearchPath::clear_local_value(), ConfigVariableSearchPath::prepend_directory(), and ConfigVariableSearchPath::prepend_path().
void ConfigFlags::invalidate_cache | ( | ) | [inline, static, protected, inherited] |
Invalidates all of the global ConfigVariable caches in the world at once, by incrementing the global_modified counter.
Definition at line 61 of file configFlags.I.
Referenced by ConfigVariableCore::clear_local_value(), ConfigPageManager::delete_explicit_page(), ConfigPageManager::make_explicit_page(), ConfigPageManager::reload_implicit_pages(), ConfigDeclaration::set_bool_word(), ConfigDeclaration::set_double_word(), ConfigDeclaration::set_int64_word(), ConfigDeclaration::set_int_word(), NotifyCategory::set_severity(), ConfigDeclaration::set_string_value(), and ConfigDeclaration::set_string_word().
bool ConfigFlags::is_cache_valid | ( | AtomicAdjust::Integer | local_modified | ) | [inline, static, protected, inherited] |
Returns true if the local object's cache is still valid (based on a comparison of the supplied local_modified value with the global_modified value).
Definition at line 24 of file configFlags.I.
Referenced by ConfigVariableString::get_value(), ConfigVariableInt64::get_value(), ConfigVariableInt::get_value(), ConfigVariableFilename::get_value(), get_value(), and ConfigVariableBool::get_value().
bool ConfigVariableBase::is_closed | ( | ) | const [inline, inherited] |
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 107 of file configVariableBase.I.
References ConfigVariableCore::is_closed().
bool ConfigVariable::is_constructed | ( | ) | const [inline, protected, inherited] |
Returns true if the constructor has been called and _core initialized, false if the constructor has not yet been called and _core is NULL.
This is intended to be placed in an assertion check, to guard against static-init ordering issues.
Definition at line 339 of file configVariable.I.
References ConfigVariable::report_unconstructed().
Referenced by ConfigVariable::clear_value(), ConfigVariable::get_bool_word(), ConfigVariable::get_default_value(), ConfigVariable::get_double_word(), ConfigVariable::get_int64_word(), ConfigVariable::get_int_word(), ConfigVariable::get_num_words(), ConfigVariable::get_string_value(), ConfigVariable::get_string_word(), ConfigVariable::has_bool_word(), ConfigVariable::has_double_word(), ConfigVariable::has_int64_word(), ConfigVariable::has_int_word(), ConfigVariable::has_string_word(), ConfigVariable::set_bool_word(), ConfigVariable::set_double_word(), ConfigVariable::set_int64_word(), ConfigVariable::set_int_word(), ConfigVariable::set_string_value(), and ConfigVariable::set_string_word().
bool ConfigVariableBase::is_dynamic | ( | ) | const [inline, inherited] |
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 143 of file configVariableBase.I.
References ConfigVariableCore::is_dynamic().
void ConfigFlags::mark_cache_valid | ( | AtomicAdjust::Integer & | local_modified | ) | [inline, static, protected, inherited] |
Updates the indicated local_modified value so that the cache will appear to be valid, until someone next calls invalidate_cache().
Definition at line 36 of file configFlags.I.
Referenced by ConfigVariableString::get_value(), ConfigVariableInt64::get_value(), ConfigVariableInt::get_value(), get_value(), and ConfigVariableBool::get_value().
ConfigVariableDouble::operator double | ( | ) | const [inline] |
Returns the variable's value.
Definition at line 83 of file configVariableDouble.I.
References get_value().
void ConfigVariableDouble::operator= | ( | double | value | ) | [inline] |
Reassigns the variable's local value.
Definition at line 73 of file configVariableDouble.I.
References set_value().
double ConfigVariableDouble::operator[] | ( | int | n | ) | const [inline] |
Returns the value of the variable's nth word.
Definition at line 103 of file configVariableDouble.I.
References get_word().
void ConfigVariableBase::record_unconstructed | ( | ) | const [protected, inherited] |
Records that this config variable was referenced before it was constructed (presumably a static-init ordering issue).
This is used to print a useful error message later, when the constructor is actually called (and we then know what the name of the variable is).
Definition at line 62 of file configVariableBase.cxx.
Referenced by ConfigVariable::report_unconstructed().
void ConfigVariable::report_unconstructed | ( | ) | const [protected, inherited] |
Displays a suitable error message when an unconstructed ConfigVariable is attempted to be used.
This normally indicates a static-init ordering issue.
Definition at line 26 of file configVariable.cxx.
References ConfigVariableBase::record_unconstructed().
Referenced by ConfigVariable::is_constructed().
void ConfigVariable::set_bool_word | ( | int | n, |
bool | value | ||
) | [inline, inherited] |
Changes the nth word to the indicated value without affecting the other words.
Definition at line 288 of file configVariable.I.
References ConfigVariable::is_constructed(), ConfigVariableCore::make_local_value(), and ConfigDeclaration::set_bool_word().
Referenced by ConfigVariableBool::set_value(), and ConfigVariableBool::set_word().
void ConfigVariable::set_double_word | ( | int | n, |
double | value | ||
) | [inline, inherited] |
Changes the nth word to the indicated value without affecting the other words.
Definition at line 324 of file configVariable.I.
References ConfigVariable::is_constructed(), ConfigVariableCore::make_local_value(), and ConfigDeclaration::set_double_word().
Referenced by set_value(), and set_word().
void ConfigVariable::set_int64_word | ( | int | n, |
PN_int64 | value | ||
) | [inline, inherited] |
Changes the nth word to the indicated value without affecting the other words.
Definition at line 312 of file configVariable.I.
References ConfigVariable::is_constructed(), ConfigVariableCore::make_local_value(), and ConfigDeclaration::set_int_word().
Referenced by ConfigVariableInt64::set_value(), and ConfigVariableInt64::set_word().
void ConfigVariable::set_int_word | ( | int | n, |
int | value | ||
) | [inline, inherited] |
Changes the nth word to the indicated value without affecting the other words.
Definition at line 300 of file configVariable.I.
References ConfigVariable::is_constructed(), ConfigVariableCore::make_local_value(), and ConfigDeclaration::set_int_word().
Referenced by ConfigVariableInt::set_value(), and ConfigVariableInt::set_word().
void ConfigVariable::set_string_value | ( | const string & | string_value | ) | [inline, inherited] |
Changes the value assigned to this variable.
This creates a local value that shadows any values defined in the .prc files, until clear_local_value() is called.
Definition at line 100 of file configVariable.I.
References ConfigVariable::is_constructed(), ConfigVariableCore::make_local_value(), and ConfigDeclaration::set_string_value().
Referenced by ConfigVariableString::set_value(), ConfigVariableInt64::set_value(), ConfigVariableInt::set_value(), ConfigVariableFilename::set_value(), set_value(), and ConfigVariableBool::set_value().
void ConfigVariable::set_string_word | ( | int | n, |
const string & | value | ||
) | [inline, inherited] |
Changes the nth word to the indicated value without affecting the other words.
Definition at line 276 of file configVariable.I.
References ConfigVariable::is_constructed(), ConfigVariableCore::make_local_value(), and ConfigDeclaration::set_string_word().
Referenced by ConfigVariableString::set_word(), and ConfigVariableFilename::set_word().
void ConfigVariableDouble::set_value | ( | double | value | ) | [inline] |
Reassigns the variable's local value.
Definition at line 113 of file configVariableDouble.I.
References ConfigVariable::set_double_word(), and ConfigVariable::set_string_value().
Referenced by operator=().
void ConfigVariableDouble::set_word | ( | int | n, |
double | value | ||
) | [inline] |
Reassigns the variable's nth value.
This makes a local copy of the variable's overall value.
Definition at line 164 of file configVariableDouble.I.
References ConfigVariable::set_double_word().
int ConfigVariableDouble::size | ( | ) | const [inline] |
Returns the number of unique words in the variable.
Definition at line 93 of file configVariableDouble.I.
References ConfigVariable::get_num_words().
bool ConfigVariableBase::was_unconstructed | ( | ) | const [protected, inherited] |
Returns true if record_unconstructed() was ever called on this pointer, false otherwise.
Definition at line 78 of file configVariableBase.cxx.
Referenced by ConfigVariableBase::ConfigVariableBase().