Panda3D
Public Member Functions | Static Public Member Functions | Friends
ConfigPage Class Reference

A page of ConfigDeclarations that may be loaded or unloaded. More...

#include "configPage.h"

List of all members.

Public Member Functions

void clear ()
 Removes all of the declarations from the page.
bool delete_declaration (ConfigDeclaration *decl)
 Removes the indicated declaration from the page and deletes it.
const ConfigDeclarationget_declaration (int n) const
 Returns the nth declaration on the page.
const string & get_name () const
 Returns the name of the page.
int get_num_declarations () const
 Returns the number of declarations on the page.
int get_page_seq () const
 Returns the sequence number of the page.
const string & get_signature () const
 Returns the raw binary signature that was found in the prc file, if any.
int get_sort () const
 Returns the explicit sort order of this particular ConfigPage.
string get_string_value (int n) const
 Returns the value assigned by the nth declaration on the page.
int get_trust_level () const
 Returns the trust level associated with this page.
string get_variable_name (int n) const
 Returns the variable named by the nth declaration on the page.
bool is_implicit () const
 Returns true if the page was loaded by implicitly searching the config path on startup, or false if it was explicitly loaded by dynamic code after initial startup.
bool is_special () const
 Returns true if this is the special "default" or "local" page, or false if it is an ordinary page, e.g.
bool is_variable_used (int n) const
 Returns true if the nth active variable on the page has been used by code, false otherwise.
ConfigDeclarationmake_declaration (const string &variable, const string &value)
 Adds the indicated variable/value pair as a new declaration on the page.
ConfigDeclarationmake_declaration (ConfigVariableCore *variable, const string &value)
 Adds the indicated variable/value pair as a new declaration on the page.
ConfigDeclarationmodify_declaration (int n)
 Returns a modifiable pointer to the nth declaration on the page.
bool operator< (const ConfigPage &other) const
 Sorts two pages in order based on the order in which their respective pages were loaded, and the order in which they appear within the same page.
void output (ostream &out) const
void output_brief_signature (ostream &out) const
 Outputs the first few hex digits of the signature.
bool read_encrypted_prc (istream &in, const string &password)
 Automatically decrypts and reads the stream, given the indicated password.
bool read_prc (istream &in)
 Reads the contents of a complete prc file, as returned by the indicated istream, into the current page file.
void set_sort (int sort)
 Changes the explicit sort order of this particular ConfigPage.
void set_trust_level (int trust_level)
 Explicitly sets the trust level on this particular page.
void write (ostream &out) const

Static Public Member Functions

static ConfigPageget_default_page ()
 Returns a pointer to the global "default page".
static ConfigPageget_local_page ()
 Returns a pointer to the global "local page".

Friends

class ConfigPageManager

Detailed Description

A page of ConfigDeclarations that may be loaded or unloaded.

Typically this represents a single .prc file that is read from disk at runtime, but it may also represent a list of declarations built up by application code and explicitly loaded.

Definition at line 33 of file configPage.h.


Member Function Documentation

Removes all of the declarations from the page.

Definition at line 119 of file configPage.cxx.

Referenced by read_prc().

Removes the indicated declaration from the page and deletes it.

Returns true if the declaration is successfully removed, false if it was not on the page.

Definition at line 305 of file configPage.cxx.

Referenced by ConfigVariableCore::clear_local_value().

Returns the nth declaration on the page.

Definition at line 335 of file configPage.cxx.

Returns a pointer to the global "default page".

This is the ConfigPage that lists all variables' original default values.

Definition at line 70 of file configPage.cxx.

Referenced by is_special(), and ConfigVariableCore::set_default_value().

Returns a pointer to the global "local page".

This is the ConfigPage that lists the locally-assigned values for any variables in the world that have such a local assignment.

Definition at line 86 of file configPage.cxx.

Referenced by ConfigVariableCore::clear_local_value(), is_special(), and ConfigVariableCore::make_local_value().

const string & ConfigPage::get_name ( ) const [inline]

Returns the name of the page.

If the page was loaded from a .prc file, this is usually the filename.

Definition at line 44 of file configPage.I.

Referenced by ConfigVariableManager::list_unused_variables(), and read_prc().

Returns the number of declarations on the page.

Definition at line 325 of file configPage.cxx.

int ConfigPage::get_page_seq ( ) const [inline]

Returns the sequence number of the page.

Sequence numbers for a particular class (implicit vs. explicit) of pages are assigned as each page is loaded; each page is given a higher sequence number than all the pages loaded before it.

The implicit_load pages, which are discovered in the file system automatically, have a different set of sequence numbers than the explicit pages.

Definition at line 101 of file configPage.I.

Referenced by operator<().

const string & ConfigPage::get_signature ( ) const [inline]

Returns the raw binary signature that was found in the prc file, if any.

This method is probably not terribly useful for most applications.

Definition at line 141 of file configPage.I.

int ConfigPage::get_sort ( ) const [inline]

Returns the explicit sort order of this particular ConfigPage.

See set_sort().

Definition at line 82 of file configPage.I.

Referenced by operator<().

string ConfigPage::get_string_value ( int  n) const

Returns the value assigned by the nth declaration on the page.

Definition at line 373 of file configPage.cxx.

int ConfigPage::get_trust_level ( ) const [inline]

Returns the trust level associated with this page.

An untrusted page is trust level 0; if the page was loaded from a signed .prc file, its trust level is the index number of the certificate that signed it. Generally, a higher trust level value represents a greater level of trust.

Definition at line 116 of file configPage.I.

string ConfigPage::get_variable_name ( int  n) const

Returns the variable named by the nth declaration on the page.

Definition at line 361 of file configPage.cxx.

bool ConfigPage::is_implicit ( ) const [inline]

Returns true if the page was loaded by implicitly searching the config path on startup, or false if it was explicitly loaded by dynamic code after initial startup.

Definition at line 71 of file configPage.I.

bool ConfigPage::is_special ( ) const [inline]

Returns true if this is the special "default" or "local" page, or false if it is an ordinary page, e.g.

an implicit page loaded from a prc file at startup, or an explicit page created by ConfigPageManager::make_explicit_page().

Definition at line 58 of file configPage.I.

References get_default_page(), and get_local_page().

bool ConfigPage::is_variable_used ( int  n) const

Returns true if the nth active variable on the page has been used by code, false otherwise.

Definition at line 385 of file configPage.cxx.

ConfigDeclaration * ConfigPage::make_declaration ( const string &  variable,
const string &  value 
)

Adds the indicated variable/value pair as a new declaration on the page.

Definition at line 273 of file configPage.cxx.

References ConfigVariableManager::make_variable().

Referenced by ConfigVariableCore::make_local_value(), and ConfigVariableCore::set_default_value().

ConfigDeclaration * ConfigPage::make_declaration ( ConfigVariableCore variable,
const string &  value 
)

Adds the indicated variable/value pair as a new declaration on the page.

Definition at line 285 of file configPage.cxx.

Returns a modifiable pointer to the nth declaration on the page.

Any modifications will appear in the output, if the page is written out with ConfigPage::write().

Definition at line 349 of file configPage.cxx.

bool ConfigPage::operator< ( const ConfigPage other) const [inline]

Sorts two pages in order based on the order in which their respective pages were loaded, and the order in which they appear within the same page.

Definition at line 24 of file configPage.I.

References get_page_seq(), and get_sort().

void ConfigPage::output_brief_signature ( ostream &  out) const

Outputs the first few hex digits of the signature.

Definition at line 407 of file configPage.cxx.

bool ConfigPage::read_encrypted_prc ( istream &  in,
const string &  password 
)

Automatically decrypts and reads the stream, given the indicated password.

Note that if the password is incorrect, the result may be garbage.

Definition at line 257 of file configPage.cxx.

References read_prc().

Referenced by ConfigPageManager::reload_implicit_pages().

bool ConfigPage::read_prc ( istream &  in)

Reads the contents of a complete prc file, as returned by the indicated istream, into the current page file.

Returns true on success, or false on some I/O error.

This is a low-level interface. Normally you do not need to call it directly. See the global functions load_prc_file() and unload_prc_file(), defined in panda/src/putil, for a higher-level interface.

Definition at line 144 of file configPage.cxx.

References clear(), and get_name().

Referenced by read_encrypted_prc(), and ConfigPageManager::reload_implicit_pages().

void ConfigPage::set_sort ( int  sort)

Changes the explicit sort order of this particular ConfigPage.

Lower-numbered pages supercede higher-numbered pages. Initially, all explicitly-loaded pages have sort value 0, and implicitly-loaded pages (found on disk) have sort value 10; you may set an individual page higher or lower to influence its priority relative to other pages.

Definition at line 106 of file configPage.cxx.

References ConfigPageManager::mark_unsorted().

void ConfigPage::set_trust_level ( int  trust_level) [inline]

Explicitly sets the trust level on this particular page.

Note that any subsequent changes to the page, or to any variable declarations on it, will reset the trust level to zero.

Definition at line 129 of file configPage.I.


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