Panda3D
Loading...
Searching...
No Matches
configPage.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file configPage.I
10 * @author drose
11 * @date 2004-10-15
12 */
13
14/**
15 * Sorts two pages in order based on the order in which their respective pages
16 * were loaded, and the order in which they appear within the same page.
17 */
18INLINE bool ConfigPage::
19operator < (const ConfigPage &other) const {
20 // The explicit sort value is the most important setting. It's usually zero
21 // unless explicitly changed.
22 if (get_sort() != other.get_sort()) {
23 return get_sort() < other.get_sort();
24 }
25
26 // Within the implicitexplicit categorization, sort by the page sequence.
27 // The higher page sequence is more important (since it was loaded later),
28 // so it gets sorted to the front of the list.
29 return get_page_seq() > other.get_page_seq();
30}
31
32/**
33 * Returns the name of the page. If the page was loaded from a .prc file,
34 * this is usually the filename.
35 */
36INLINE const std::string &ConfigPage::
37get_name() const {
38 return _name;
39}
40
41/**
42 * Returns true if this is the special "default" or "local" page, or false if
43 * it is an ordinary page, e.g. an implicit page loaded from a prc file at
44 * startup, or an explicit page created by
45 * ConfigPageManager::make_explicit_page().
46 */
47INLINE bool ConfigPage::
48is_special() const {
49 return this == get_default_page() || this == get_local_page();
50}
51
52/**
53 * Returns true if the page was loaded by implicitly searching the config path
54 * on startup, or false if it was explicitly loaded by dynamic code after
55 * initial startup.
56 */
57INLINE bool ConfigPage::
58is_implicit() const {
59 return _implicit_load;
60}
61
62/**
63 * Returns the explicit sort order of this particular ConfigPage. See
64 * set_sort().
65 */
66INLINE int ConfigPage::
67get_sort() const {
68 return _sort;
69}
70
71/**
72 * Returns the sequence number of the page.
73 *
74 * Sequence numbers for a particular class (implicit vs. explicit) of pages
75 * are assigned as each page is loaded; each page is given a higher sequence
76 * number than all the pages loaded before it.
77 *
78 * The implicit_load pages, which are discovered in the file system
79 * automatically, have a different set of sequence numbers than the explicit
80 * pages.
81 */
82INLINE int ConfigPage::
83get_page_seq() const {
84 return _page_seq;
85}
86
87/**
88 * Returns the trust level associated with this page. An untrusted page is
89 * trust level 0; if the page was loaded from a signed .prc file, its trust
90 * level is the index number of the certificate that signed it. Generally, a
91 * higher trust level value represents a greater level of trust.
92 */
93INLINE int ConfigPage::
94get_trust_level() const {
95 return _trust_level;
96}
97
98/**
99 * Explicitly sets the trust level on this particular page. Note that any
100 * subsequent changes to the page, or to any variable declarations on it, will
101 * reset the trust level to zero.
102 */
103INLINE void ConfigPage::
104set_trust_level(int trust_level) {
105 _trust_level = trust_level;
106}
107
108/**
109 * Returns the raw binary signature that was found in the prc file, if any.
110 * This method is probably not terribly useful for most applications.
111 */
112INLINE const std::string &ConfigPage::
113get_signature() const {
114 return _signature;
115}
116
117
118/**
119 * Called internally when the page is changed through some API operation, this
120 * is intended as a hook to mark the page untrusted.
121 */
122INLINE void ConfigPage::
123make_dirty() {
124 _trust_level = 0;
125}
126
127INLINE std::ostream &
128operator << (std::ostream &out, const ConfigPage &page) {
129 page.output(out);
130 return out;
131}
A page of ConfigDeclarations that may be loaded or unloaded.
Definition configPage.h:30
bool operator<(const ConfigPage &other) const
Sorts two pages in order based on the order in which their respective pages were loaded,...
Definition configPage.I:19
get_sort
Returns the explicit sort order of this particular ConfigPage.
Definition configPage.h:52
get_signature
Returns the raw binary signature that was found in the prc file, if any.
Definition configPage.h:60
set_trust_level
Explicitly sets the trust level on this particular page.
Definition configPage.h:59
static ConfigPage * get_default_page()
Returns a pointer to the global "default page".
get_page_seq
Returns the sequence number of the page.
Definition configPage.h:58
static ConfigPage * get_local_page()
Returns a pointer to the global "local page".
is_implicit
Returns true if the page was loaded by implicitly searching the config path on startup,...
Definition configPage.h:48
is_special
Returns true if this is the special "default" or "local" page, or false if it is an ordinary page,...
Definition configPage.h:47
get_trust_level
Returns the trust level associated with this page.
Definition configPage.h:59
get_name
Returns the name of the page.
Definition configPage.h:43