Panda3D
 All Classes Functions Variables Enumerations
configPage.I
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   // The explicit sort value is the most important setting.  It's
00026   // usually zero unless explicitly changed.
00027   if (get_sort() != other.get_sort()) {
00028     return get_sort() < other.get_sort();
00029   }
00030 
00031   // Within the implicit/explicit categorization, sort by the page
00032   // sequence.  The higher page sequence is more important (since it
00033   // was loaded later), so it gets sorted to the front of the list.
00034   return get_page_seq() > other.get_page_seq();
00035 }
00036 
00037 ////////////////////////////////////////////////////////////////////
00038 //     Function: ConfigPage::get_name
00039 //       Access: Published
00040 //  Description: Returns the name of the page.  If the page was loaded
00041 //               from a .prc file, this is usually the filename.
00042 ////////////////////////////////////////////////////////////////////
00043 INLINE const string &ConfigPage::
00044 get_name() const {
00045   return _name;
00046 }
00047 
00048 ////////////////////////////////////////////////////////////////////
00049 //     Function: ConfigPage::is_special
00050 //       Access: Published
00051 //  Description: Returns true if this is the special "default" or
00052 //               "local" page, or false if it is an ordinary page,
00053 //               e.g. an implicit page loaded from a prc file at
00054 //               startup, or an explicit page created by
00055 //               ConfigPageManager::make_explicit_page().
00056 ////////////////////////////////////////////////////////////////////
00057 INLINE bool ConfigPage::
00058 is_special() const {
00059   return this == get_default_page() || this == get_local_page();
00060 }
00061 
00062 ////////////////////////////////////////////////////////////////////
00063 //     Function: ConfigPage::is_implicit
00064 //       Access: Published
00065 //  Description: Returns true if the page was loaded by implicitly
00066 //               searching the config path on startup, or false if it
00067 //               was explicitly loaded by dynamic code after initial
00068 //               startup.
00069 ////////////////////////////////////////////////////////////////////
00070 INLINE bool ConfigPage::
00071 is_implicit() const {
00072   return _implicit_load;
00073 }
00074 
00075 ////////////////////////////////////////////////////////////////////
00076 //     Function: ConfigPage::get_sort
00077 //       Access: Published
00078 //  Description: Returns the explicit sort order of this particular
00079 //               ConfigPage.  See set_sort().
00080 ////////////////////////////////////////////////////////////////////
00081 INLINE int ConfigPage::
00082 get_sort() const {
00083   return _sort;
00084 }
00085 
00086 ////////////////////////////////////////////////////////////////////
00087 //     Function: ConfigPage::get_page_seq
00088 //       Access: Published
00089 //  Description: Returns the sequence number of the page.  
00090 //
00091 //               Sequence numbers for a particular class (implicit
00092 //               vs. explicit) of pages are assigned as each page is
00093 //               loaded; each page is given a higher sequence number
00094 //               than all the pages loaded before it.
00095 //
00096 //               The implicit_load pages, which are discovered in the
00097 //               file system automatically, have a different set of
00098 //               sequence numbers than the explicit pages.
00099 ////////////////////////////////////////////////////////////////////
00100 INLINE int ConfigPage::
00101 get_page_seq() const {
00102   return _page_seq;
00103 }
00104 
00105 ////////////////////////////////////////////////////////////////////
00106 //     Function: ConfigPage::get_trust_level
00107 //       Access: Published
00108 //  Description: Returns the trust level associated with this page.
00109 //               An untrusted page is trust level 0; if the page was
00110 //               loaded from a signed .prc file, its trust level is
00111 //               the index number of the certificate that signed it.
00112 //               Generally, a higher trust level value represents
00113 //               a greater level of trust.
00114 ////////////////////////////////////////////////////////////////////
00115 INLINE int ConfigPage::
00116 get_trust_level() const {
00117   return _trust_level;
00118 }
00119 
00120 ////////////////////////////////////////////////////////////////////
00121 //     Function: ConfigPage::set_trust_level
00122 //       Access: Published
00123 //  Description: Explicitly sets the trust level on this particular
00124 //               page.  Note that any subsequent changes to the page,
00125 //               or to any variable declarations on it, will reset the
00126 //               trust level to zero.
00127 ////////////////////////////////////////////////////////////////////
00128 INLINE void ConfigPage::
00129 set_trust_level(int trust_level) {
00130   _trust_level = trust_level;
00131 }
00132 
00133 ////////////////////////////////////////////////////////////////////
00134 //     Function: ConfigPage::get_signature
00135 //       Access: Published
00136 //  Description: Returns the raw binary signature that was found in
00137 //               the prc file, if any.  This method is probably not
00138 //               terribly useful for most applications.
00139 ////////////////////////////////////////////////////////////////////
00140 INLINE const string &ConfigPage::
00141 get_signature() const {
00142   return _signature;
00143 }
00144 
00145 
00146 ////////////////////////////////////////////////////////////////////
00147 //     Function: ConfigPage::make_dirty
00148 //       Access: Private
00149 //  Description: Called internally when the page is changed through
00150 //               some API operation, this is intended as a hook to
00151 //               mark the page untrusted.
00152 ////////////////////////////////////////////////////////////////////
00153 INLINE void ConfigPage::
00154 make_dirty() {
00155   _trust_level = 0;
00156 }
00157 
00158 INLINE ostream &
00159 operator << (ostream &out, const ConfigPage &page) {
00160   page.output(out);
00161   return out;
00162 }
 All Classes Functions Variables Enumerations