Panda3D
|
00001 // Filename: configPage.I 00002 // Created by: drose (15Oct04) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: ConfigPage::operator < 00018 // Access: Public 00019 // Description: Sorts two pages in order based on the order in 00020 // which their respective pages were loaded, and the 00021 // order in which they appear within the same page. 00022 //////////////////////////////////////////////////////////////////// 00023 INLINE bool ConfigPage:: 00024 operator < (const ConfigPage &other) const { 00025 if (is_implicit() != other.is_implicit()) { 00026 // Explicitly-loaded pages are more important than 00027 // implicitly-loaded pages, so put the implicit pages at the end 00028 // of the list. 00029 return (int)is_implicit() < (int)other.is_implicit(); 00030 } 00031 00032 // Within the implicit/explicit categorization, sort by the page 00033 // sequence. The higher page sequence is more important (since it 00034 // was loaded later), so it gets sorted to the front of the list. 00035 return get_page_seq() > other.get_page_seq(); 00036 } 00037 00038 //////////////////////////////////////////////////////////////////// 00039 // Function: ConfigPage::get_name 00040 // Access: Published 00041 // Description: Returns the name of the page. If the page was loaded 00042 // from a .prc file, this is usually the filename. 00043 //////////////////////////////////////////////////////////////////// 00044 INLINE const string &ConfigPage:: 00045 get_name() const { 00046 return _name; 00047 } 00048 00049 //////////////////////////////////////////////////////////////////// 00050 // Function: ConfigPage::is_special 00051 // Access: Published 00052 // Description: Returns true if this is the special "default" or 00053 // "local" page, or false if it is an ordinary page, 00054 // e.g. an implicit page loaded from a prc file at 00055 // startup, or an explicit page created by 00056 // ConfigPageManager::make_explicit_page(). 00057 //////////////////////////////////////////////////////////////////// 00058 INLINE bool ConfigPage:: 00059 is_special() const { 00060 return this == get_default_page() || this == get_local_page(); 00061 } 00062 00063 //////////////////////////////////////////////////////////////////// 00064 // Function: ConfigPage::is_implicit 00065 // Access: Published 00066 // Description: Returns true if the page was loaded by implicitly 00067 // searching the config path on startup, or false if it 00068 // was explicitly loaded by dynamic code after initial 00069 // startup. 00070 //////////////////////////////////////////////////////////////////// 00071 INLINE bool ConfigPage:: 00072 is_implicit() const { 00073 return _implicit_load; 00074 } 00075 00076 //////////////////////////////////////////////////////////////////// 00077 // Function: ConfigPage::get_page_seq 00078 // Access: Published 00079 // Description: Returns the sequence number of the page. 00080 // 00081 // Sequence numbers for a particular class (implicit 00082 // vs. explicit) of pages are assigned as each page is 00083 // loaded; each page is given a higher sequence number 00084 // than all the pages loaded before it. 00085 // 00086 // The implicit_load pages, which are discovered in the 00087 // file system automatically, have a different set of 00088 // sequence numbers than the explicit pages. 00089 //////////////////////////////////////////////////////////////////// 00090 INLINE int ConfigPage:: 00091 get_page_seq() const { 00092 return _page_seq; 00093 } 00094 00095 //////////////////////////////////////////////////////////////////// 00096 // Function: ConfigPage::get_trust_level 00097 // Access: Published 00098 // Description: Returns the trust level associated with this page. 00099 // An untrusted page is trust level 0; if the page was 00100 // loaded from a signed .prc file, its trust level is 00101 // the index number of the certificate that signed it. 00102 // Generally, a higher trust level value represents 00103 // a greater level of trust. 00104 //////////////////////////////////////////////////////////////////// 00105 INLINE int ConfigPage:: 00106 get_trust_level() const { 00107 return _trust_level; 00108 } 00109 00110 //////////////////////////////////////////////////////////////////// 00111 // Function: ConfigPage::set_trust_level 00112 // Access: Published 00113 // Description: Explicitly sets the trust level on this particular 00114 // page. Note that any subsequent changes to the page, 00115 // or to any variable declarations on it, will reset the 00116 // trust level to zero. 00117 //////////////////////////////////////////////////////////////////// 00118 INLINE void ConfigPage:: 00119 set_trust_level(int trust_level) { 00120 _trust_level = trust_level; 00121 } 00122 00123 //////////////////////////////////////////////////////////////////// 00124 // Function: ConfigPage::get_signature 00125 // Access: Published 00126 // Description: Returns the raw binary signature that was found in 00127 // the prc file, if any. This method is probably not 00128 // terribly useful for most applications. 00129 //////////////////////////////////////////////////////////////////// 00130 INLINE const string &ConfigPage:: 00131 get_signature() const { 00132 return _signature; 00133 } 00134 00135 00136 //////////////////////////////////////////////////////////////////// 00137 // Function: ConfigPage::make_dirty 00138 // Access: Private 00139 // Description: Called internally when the page is changed through 00140 // some API operation, this is intended as a hook to 00141 // mark the page untrusted. 00142 //////////////////////////////////////////////////////////////////// 00143 INLINE void ConfigPage:: 00144 make_dirty() { 00145 _trust_level = 0; 00146 } 00147 00148 INLINE ostream & 00149 operator << (ostream &out, const ConfigPage &page) { 00150 page.output(out); 00151 return out; 00152 }