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