Panda3D
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  */
18 INLINE bool ConfigPage::
19 operator < (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  */
36 INLINE const std::string &ConfigPage::
37 get_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  */
47 INLINE bool ConfigPage::
48 is_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  */
57 INLINE bool ConfigPage::
58 is_implicit() const {
59  return _implicit_load;
60 }
61 
62 /**
63  * Returns the explicit sort order of this particular ConfigPage. See
64  * set_sort().
65  */
66 INLINE int ConfigPage::
67 get_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  */
82 INLINE int ConfigPage::
83 get_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  */
93 INLINE int ConfigPage::
94 get_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  */
103 INLINE void ConfigPage::
104 set_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  */
112 INLINE const std::string &ConfigPage::
113 get_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  */
122 INLINE void ConfigPage::
123 make_dirty() {
124  _trust_level = 0;
125 }
126 
127 INLINE std::ostream &
128 operator << (std::ostream &out, const ConfigPage &page) {
129  page.output(out);
130  return out;
131 }
set_trust_level
Explicitly sets the trust level on this particular page.
Definition: configPage.h:59
get_sort
Returns the explicit sort order of this particular ConfigPage.
Definition: configPage.h:52
static ConfigPage * get_local_page()
Returns a pointer to the global "local page".
Definition: configPage.cxx:77
static ConfigPage * get_default_page()
Returns a pointer to the global "default page".
Definition: configPage.cxx:64
get_page_seq
Returns the sequence number of the page.
Definition: configPage.h:58
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