Panda3D
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes

ConfigVariableList Class Reference

This class is similar to ConfigVariable, but it reports its value as a list of strings. More...

#include "configVariableList.h"

Inheritance diagram for ConfigVariableList:
ConfigVariableBase ConfigFlags

List of all members.

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

 ConfigVariableList (const string &name, 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.
const string & get_description () const
 Returns the brief description of this variable, if it has been defined.
int get_flags () const
 Returns the flags value as set by set_flags().
const string & get_name () const
 Returns the name of the variable.
int get_num_unique_values () const
 Returns the number of unique values in the variable.
int get_num_values () const
 Returns the number of values in the variable.
string get_string_value (int n) const
 Returns the nth value of the variable.
int get_trust_level () const
 Returns the minimum trust_level a prc file must demonstrate in order to redefine the value for this variable.
string get_unique_value (int n) const
 Returns the nth unique value of the variable.
ValueType get_value_type () const
 Returns the stated type of this variable.
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_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.
string operator[] (int n) const
 Returns the nth unique value of the variable.
void output (ostream &out) const
int size () const
 Returns the number of unique values of the variable.
void write (ostream &out) const

Protected Types

typedef pset< const
ConfigVariableBase * > 
Unconstructed

Protected Member Functions

void record_unconstructed () const
 Records that this config variable was referenced before it was constructed (presumably a static-init ordering issue).
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

Detailed Description

This class is similar to ConfigVariable, but it reports its value as a list of strings.

In this special case, all of the declarations of the variable are returned as the elements of this list, in order.

Note that this is different from a normal ConfigVariableString, which just returns its topmost value, which can optionally be treated as a number of discrete words by dividing it at the spaces.

A ConfigVariableList cannot be modified locally.

Definition at line 35 of file configVariableList.h.


Member Function Documentation

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

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

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

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 ConfigVariableList::get_num_unique_values ( ) const [inline]

Returns the number of unique values in the variable.

Definition at line 80 of file configVariableList.I.

References ConfigVariableCore::get_num_unique_references().

Referenced by Texture::adjust_size(), VirtualFileSystem::get_global_ptr(), and size().

int ConfigVariableList::get_num_values ( ) const [inline]

Returns the number of values in the variable.

Definition at line 54 of file configVariableList.I.

References ConfigVariableCore::get_num_trusted_references().

string ConfigVariableList::get_string_value ( int  n) const [inline]

Returns the nth value of the variable.

Definition at line 65 of file configVariableList.I.

References ConfigDeclaration::get_string_value(), and ConfigVariableCore::get_trusted_reference().

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

string ConfigVariableList::get_unique_value ( int  n) const [inline]

Returns the nth unique value of the variable.

Definition at line 91 of file configVariableList.I.

References ConfigDeclaration::get_string_value(), and ConfigVariableCore::get_unique_reference().

Referenced by Texture::adjust_size(), VirtualFileSystem::get_global_ptr(), and operator[]().

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

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 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]
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(), ConfigVariableDouble::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 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(), ConfigVariableDouble::get_value(), and ConfigVariableBool::get_value().

string ConfigVariableList::operator[] ( int  n) const [inline]

Returns the nth unique value of the variable.

Note that the indexing operator returns the list of unique values, and so the maximum range is get_num_unique_values().

Definition at line 119 of file configVariableList.I.

References get_unique_value().

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

int ConfigVariableList::size ( ) const [inline]

Returns the number of unique values of the variable.

Definition at line 106 of file configVariableList.I.

References get_num_unique_values().

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


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations