Panda3D

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
ConfigPage Class Reference

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

`#include "configPage.h"`

## 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 ConfigDeclaration * | get_declaration (size_t n) const
| Returns the nth declaration on the page.
const std::string & | get_name () const
size_t | get_num_declarations () const
int | get_page_seq () const
const std::string & | get_signature () const
int | get_sort () const
std::string | get_string_value (size_t n) const
| Returns the value assigned by the nth declaration on the page.
int | get_trust_level () const
std::string | get_variable_name (size_t n) const
| Returns the variable named by the nth declaration on the page.
bool | is_implicit () const
bool | is_special () const
bool | is_variable_used (size_t n) const
| Returns true if the nth active variable on the page has been used by code, false otherwise.
ConfigDeclaration * | make_declaration (ConfigVariableCore *variable, const std::string &value)
| Adds the indicated variable/value pair as a new declaration on the page.
ConfigDeclaration * | make_declaration (const std::string &variable, const std::string &value)
| Adds the indicated variable/value pair as a new declaration on the page.
ConfigDeclaration * | modify_declaration (size_t n)
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 (std::ostream &out) const
void | output_brief_signature (std::ostream &out) const
| Outputs the first few hex digits of the signature.
bool | read_encrypted_prc (std::istream &in, const std::string &password)
| Automatically decrypts and reads the stream, given the indicated password.
bool | read_prc (std::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)
void | set_trust_level (int trust_level)
void | write (std::ostream &out) const

## Static Public Member Functions
static ConfigPage * | get_default_page ()
| Returns a pointer to the global "default page".
static ConfigPage * | get_local_page ()
| Returns a pointer to the global "local page".

## Public Attributes
| get_name
| Returns the name of the page.
| get_num_declarations
| Returns the number of declarations on the page.
| get_page_seq
| Returns the sequence number of the page.
| get_signature
| Returns the raw binary signature that was found in the prc file, if any.
| get_sort
| Returns the explicit sort order of this particular ConfigPage.
| get_trust_level
| Returns the trust level associated with this page.
| is_implicit
| 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.
| is_special
| Returns true if this is the special "default" or "local" page, or false if it is an ordinary page, e.g.
| modify_declaration
| Returns a modifiable pointer to the nth declaration on the page.
| set_sort
| Changes the explicit sort order of this particular ConfigPage.
| set_trust_level
| Explicitly sets the trust level on this particular 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 30 of file configPage.h.

## Member Function Documentation

## ◆ clear()

void ConfigPage::clear | ( |  | ) |

Removes all of the declarations from the page.

Definition at line 102 of file configPage.cxx.

References clear().

Referenced by clear(), and read_prc().

## ◆ delete_declaration()

bool ConfigPage::delete_declaration | ( | ConfigDeclaration * | decl | ) |

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 262 of file configPage.cxx.

Referenced by ConfigVariableCore::clear_local_value().

## ◆ get_declaration()

const ConfigDeclaration * ConfigPage::get_declaration | ( | size_t | n | ) | const

Returns the nth declaration on the page.

Definition at line 288 of file configPage.cxx.

## ◆ get_default_page()

ConfigPage * ConfigPage::get_default_page | ( |  | ) |
| static

Returns a pointer to the global "default page".

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

Definition at line 63 of file configPage.cxx.

## ◆ get_local_page()

ConfigPage * ConfigPage::get_local_page | ( |  | ) |
| static

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 76 of file configPage.cxx.

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

## ◆ get_string_value()

string ConfigPage::get_string_value | ( | size_t | n | ) | const

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

Definition at line 317 of file configPage.cxx.

## ◆ get_variable_name()

string ConfigPage::get_variable_name | ( | size_t | n | ) | const

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

Definition at line 308 of file configPage.cxx.

## ◆ is_variable_used()

bool ConfigPage::is_variable_used | ( | size_t | n | ) | const

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

Definition at line 327 of file configPage.cxx.

## ◆ make_declaration() [1/2]

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

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

Definition at line 245 of file configPage.cxx.

## ◆ make_declaration() [2/2]

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

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

Definition at line 236 of file configPage.cxx.

References make_declaration(), and ConfigVariableManager::make_variable().

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

## ◆ operator<()

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 18 of file configPage.I.

References get_page_seq, and get_sort.

## ◆ output()

void ConfigPage::output | ( | std::ostream & | out | ) | const

Definition at line 336 of file configPage.cxx.

## ◆ output_brief_signature()

void ConfigPage::output_brief_signature | ( | std::ostream & | out | ) | const

Outputs the first few hex digits of the signature.

Definition at line 345 of file configPage.cxx.

## ◆ read_encrypted_prc()

bool ConfigPage::read_encrypted_prc | ( | std::istream & | in,
|  | const std::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 223 of file configPage.cxx.

References read_prc().

Referenced by ConfigPageManager::reload_implicit_pages().

## ◆ read_prc()

bool ConfigPage::read_prc | ( | std::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 123 of file configPage.cxx.

References clear(), and get_name.

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

## ◆ write()

void ConfigPage::write | ( | std::ostream & | out | ) | const

Definition at line 370 of file configPage.cxx.

## Friends And Related Symbol Documentation

## ◆ ConfigPageManager

friend class ConfigPageManager
| friend

Definition at line 109 of file configPage.h.

## Member Data Documentation

## ◆ get_name

const std::string & ConfigPage::get_name
| inline

Returns the name of the page.

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

Definition at line 43 of file configPage.h.

Referenced by read_prc().

## ◆ get_num_declarations

size_t ConfigPage::get_num_declarations

Returns the number of declarations on the page.

Definition at line 77 of file configPage.h.

## ◆ get_page_seq

int ConfigPage::get_page_seq
| 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 58 of file configPage.h.

Referenced by operator<().

## ◆ get_signature

const std::string & ConfigPage::get_signature
| 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 60 of file configPage.h.

## ◆ get_sort

int ConfigPage::get_sort
| inline

Returns the explicit sort order of this particular ConfigPage.

See set_sort().

Definition at line 52 of file configPage.h.

Referenced by operator<().

## ◆ get_trust_level

int ConfigPage::get_trust_level
| 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 59 of file configPage.h.

## ◆ is_implicit

bool ConfigPage::is_implicit
| 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 48 of file configPage.h.

## ◆ is_special

bool ConfigPage::is_special
| 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 47 of file configPage.h.

## ◆ modify_declaration

ConfigDeclaration * ConfigPage::modify_declaration

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 77 of file configPage.h.

## ◆ set_sort

void ConfigPage::set_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 52 of file configPage.h.

## ◆ set_trust_level

void ConfigPage::set_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 59 of file configPage.h.

Referenced by load_prc_file_data().

The documentation for this class was generated from the following files:

- dtool/src/prc/configPage.h
- dtool/src/prc/configPage.cxx
- dtool/src/prc/configPage.I