Panda3D
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
ConfigPage Class Reference

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

Public Member Functions

 clear ()
 Removes all of the declarations from the page. More...
 
bool deleteDeclaration (ConfigDeclaration decl)
 Removes the indicated declaration from the page and deletes it. More...
 
const ConfigDeclaration getDeclaration (int n)
 Returns the nth declaration on the page. More...
 
str getName ()
 Returns the name of the page. More...
 
int getNumDeclarations ()
 Returns the number of declarations on the page. More...
 
int getPageSeq ()
 Returns the sequence number of the page. More...
 
str getSignature ()
 Returns the raw binary signature that was found in the prc file, if any. More...
 
int getSort ()
 Returns the explicit sort order of this particular ConfigPage. More...
 
str getStringValue (int n)
 Returns the value assigned by the nth declaration on the page. More...
 
int getTrustLevel ()
 Returns the trust level associated with this page. More...
 
str getVariableName (int n)
 Returns the variable named by the nth declaration on the page. More...
 
bool isImplicit ()
 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. More...
 
bool isSpecial ()
 Returns true if this is the special "default" or "local" page, or false if it is an ordinary page, e.g. More...
 
bool isVariableUsed (int n)
 Returns true if the nth active variable on the page has been used by code, false otherwise. More...
 
ConfigDeclaration makeDeclaration (ConfigVariableCore variable, str value)
 Adds the indicated variable/value pair as a new declaration on the page. More...
 
ConfigDeclaration makeDeclaration (str variable, str value)
 Adds the indicated variable/value pair as a new declaration on the page. More...
 
ConfigDeclaration modifyDeclaration (int n)
 Returns a modifiable pointer to the nth declaration on the page. More...
 
 output (Ostream out)
 
 outputBriefSignature (Ostream out)
 Outputs the first few hex digits of the signature. More...
 
bool readEncryptedPrc (Istream in, str password)
 Automatically decrypts and reads the stream, given the indicated password. More...
 
bool readPrc (Istream in)
 Reads the contents of a complete prc file, as returned by the indicated istream, into the current page file. More...
 
 setSort (int sort)
 Changes the explicit sort order of this particular ConfigPage. More...
 
 setTrustLevel (int trust_level)
 Explicitly sets the trust level on this particular page. More...
 
 write (Ostream out)
 

Static Public Member Functions

static ConfigPage getDefaultPage ()
 Returns a pointer to the global "default page". More...
 
static ConfigPage getLocalPage ()
 Returns a pointer to the global "local page". More...
 

Public Attributes

ConfigDeclaration declarations []
 
bool 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. More...
 
const String name
 Returns the name of the page. More...
 
int page_seq
 Returns the sequence number of the page. More...
 
const String signature
 Returns the raw binary signature that was found in the prc file, if any. More...
 
int sort
 Returns the explicit sort order of this particular ConfigPage. More...
 
bool special
 Returns true if this is the special "default" or "local" page, or false if it is an ordinary page, e.g. More...
 
int trust_level
 Returns the trust level associated with this page. More...
 

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.

Member Function Documentation

◆ clear()

clear ( )

Removes all of the declarations from the page.

◆ deleteDeclaration()

bool deleteDeclaration ( 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.

◆ getDeclaration()

const ConfigDeclaration getDeclaration ( int  n)

Returns the nth declaration on the page.

◆ getDefaultPage()

static ConfigPage getDefaultPage ( )
static

Returns a pointer to the global "default page".

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

◆ getLocalPage()

static ConfigPage getLocalPage ( )
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.

◆ getName()

str getName ( )

Returns the name of the page.

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

◆ getNumDeclarations()

int getNumDeclarations ( )

Returns the number of declarations on the page.

◆ getPageSeq()

int getPageSeq ( )

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.

◆ getSignature()

str getSignature ( )

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

This method is probably not terribly useful for most applications.

◆ getSort()

int getSort ( )

Returns the explicit sort order of this particular ConfigPage.

See set_sort().

◆ getStringValue()

str getStringValue ( int  n)

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

◆ getTrustLevel()

int getTrustLevel ( )

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.

◆ getVariableName()

str getVariableName ( int  n)

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

◆ isImplicit()

bool isImplicit ( )

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.

◆ isSpecial()

bool isSpecial ( )

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

◆ isVariableUsed()

bool isVariableUsed ( int  n)

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

◆ makeDeclaration() [1/2]

ConfigDeclaration makeDeclaration ( ConfigVariableCore  variable,
str  value 
)

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

◆ makeDeclaration() [2/2]

ConfigDeclaration makeDeclaration ( str  variable,
str  value 
)

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

◆ modifyDeclaration()

ConfigDeclaration modifyDeclaration ( int  n)

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

◆ output()

output ( Ostream  out)

◆ outputBriefSignature()

outputBriefSignature ( Ostream  out)

Outputs the first few hex digits of the signature.

◆ readEncryptedPrc()

bool readEncryptedPrc ( Istream  in,
str  password 
)

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

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

◆ readPrc()

bool readPrc ( 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.

◆ setSort()

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

◆ setTrustLevel()

setTrustLevel ( int  trust_level)

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.

◆ write()

write ( Ostream  out)

Member Data Documentation

◆ declarations

ConfigDeclaration declarations[]

◆ implicit

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

◆ name

const String name

Returns the name of the page.

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

◆ page_seq

int page_seq

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.

◆ signature

const String signature

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

This method is probably not terribly useful for most applications.

◆ sort

int sort

Returns the explicit sort order of this particular ConfigPage.

See set_sort().

◆ special

bool special

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

◆ trust_level

int trust_level

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.