00001 // Filename: configPageManager.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: ConfigPageManager::loaded_implicit_pages 00018 // Access: Published 00019 // Description: Returns true if the implicit *.prc files have already 00020 // been loaded, false otherwise. Normally this will 00021 // only be false briefly before startup. 00022 //////////////////////////////////////////////////////////////////// 00023 INLINE bool ConfigPageManager:: 00024 loaded_implicit_pages() const { 00025 return _loaded_implicit; 00026 } 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Function: ConfigPageManager::load_implicit_pages 00030 // Access: Published 00031 // Description: Searches the PRC_DIR and/or PRC_PATH directories for 00032 // *.prc files and loads them in as pages. This is 00033 // normally called automatically at startup time, when 00034 // the first variable's value is referenced. See also 00035 // reload_implicit_pages(). 00036 //////////////////////////////////////////////////////////////////// 00037 INLINE void ConfigPageManager:: 00038 load_implicit_pages() { 00039 if (!_loaded_implicit) { 00040 reload_implicit_pages(); 00041 } 00042 } 00043 00044 //////////////////////////////////////////////////////////////////// 00045 // Function: ConfigPageManager::get_search_path 00046 // Access: Published 00047 // Description: Returns the search path used to locate implicit .prc 00048 // files. This is determined by the PRC_DIR and 00049 // PRC_PATH environment variables. The object returned 00050 // by this method may be modified to change the path at 00051 // runtime, and then reload_implicit_pages() called. 00052 //////////////////////////////////////////////////////////////////// 00053 INLINE DSearchPath &ConfigPageManager:: 00054 get_search_path() { 00055 load_implicit_pages(); 00056 return _search_path; 00057 } 00058 00059 //////////////////////////////////////////////////////////////////// 00060 // Function: ConfigPageManager::get_num_prc_patterns 00061 // Access: Published 00062 // Description: Returns the number of patterns, like "*.prc", that 00063 // are compiled in that will be searched for as default 00064 // config filenames. Normally there is only one 00065 // pattern, and it is "*.prc", but others may be 00066 // specified with the PRC_FILENAME variable in 00067 // Config.pp. 00068 //////////////////////////////////////////////////////////////////// 00069 INLINE int ConfigPageManager:: 00070 get_num_prc_patterns() const { 00071 return _prc_patterns.size(); 00072 } 00073 00074 //////////////////////////////////////////////////////////////////// 00075 // Function: ConfigPageManager::get_prc_pattern 00076 // Access: Published 00077 // Description: Returns the nth filename pattern that will be 00078 // considered a match as a valid config file. See 00079 // get_num_prc_patterns(). 00080 //////////////////////////////////////////////////////////////////// 00081 INLINE string ConfigPageManager:: 00082 get_prc_pattern(int n) const { 00083 nassertr(n >= 0 && n < (int)_prc_patterns.size(), string()); 00084 return _prc_patterns[n].get_pattern(); 00085 } 00086 00087 //////////////////////////////////////////////////////////////////// 00088 // Function: ConfigPageManager::get_num_prc_encrypted_patterns 00089 // Access: Published 00090 // Description: Returns the number of patterns, like "*.pre", that 00091 // are compiled in that will be searched for as special 00092 // config files that are understood to be encrypted. 00093 //////////////////////////////////////////////////////////////////// 00094 INLINE int ConfigPageManager:: 00095 get_num_prc_encrypted_patterns() const { 00096 return _prc_encrypted_patterns.size(); 00097 } 00098 00099 //////////////////////////////////////////////////////////////////// 00100 // Function: ConfigPageManager::get_prc_encrypted_pattern 00101 // Access: Published 00102 // Description: Returns the nth filename pattern that will be 00103 // considered a match as a valid encrypted config 00104 // file. See get_num_prc_encrypted_patterns(). 00105 //////////////////////////////////////////////////////////////////// 00106 INLINE string ConfigPageManager:: 00107 get_prc_encrypted_pattern(int n) const { 00108 nassertr(n >= 0 && n < (int)_prc_patterns.size(), string()); 00109 return _prc_encrypted_patterns[n].get_pattern(); 00110 } 00111 00112 //////////////////////////////////////////////////////////////////// 00113 // Function: ConfigPageManager::get_num_prc_executable_patterns 00114 // Access: Published 00115 // Description: Returns the number of patterns, like "*.exe", that 00116 // are compiled in that will be searched for as special 00117 // config files that are to be executed as a program, 00118 // and their output taken to be input. This is normally 00119 // empty. 00120 //////////////////////////////////////////////////////////////////// 00121 INLINE int ConfigPageManager:: 00122 get_num_prc_executable_patterns() const { 00123 return _prc_executable_patterns.size(); 00124 } 00125 00126 //////////////////////////////////////////////////////////////////// 00127 // Function: ConfigPageManager::get_prc_executable_pattern 00128 // Access: Published 00129 // Description: Returns the nth filename pattern that will be 00130 // considered a match as a valid executable-style config 00131 // file. See get_num_prc_executable_patterns(). 00132 //////////////////////////////////////////////////////////////////// 00133 INLINE string ConfigPageManager:: 00134 get_prc_executable_pattern(int n) const { 00135 nassertr(n >= 0 && n < (int)_prc_patterns.size(), string()); 00136 return _prc_executable_patterns[n].get_pattern(); 00137 } 00138 00139 //////////////////////////////////////////////////////////////////// 00140 // Function: ConfigPageManager::get_num_implicit_pages 00141 // Access: Published 00142 // Description: Returns the current number of implicitly-loaded 00143 // ConfigPages in the world. These represent files that 00144 // were automatically discovered on the disk as .prc 00145 // files. 00146 //////////////////////////////////////////////////////////////////// 00147 INLINE int ConfigPageManager:: 00148 get_num_implicit_pages() const { 00149 return _implicit_pages.size(); 00150 } 00151 00152 //////////////////////////////////////////////////////////////////// 00153 // Function: ConfigPageManager::get_implicit_page 00154 // Access: Published 00155 // Description: Returns the nth implicit ConfigPage in the world. 00156 // See get_num_implicit_pages(). 00157 //////////////////////////////////////////////////////////////////// 00158 INLINE ConfigPage *ConfigPageManager:: 00159 get_implicit_page(int n) const { 00160 check_sort_pages(); 00161 nassertr(n >= 0 && n < (int)_implicit_pages.size(), (ConfigPage *)NULL); 00162 return _implicit_pages[n]; 00163 } 00164 00165 //////////////////////////////////////////////////////////////////// 00166 // Function: ConfigPageManager::get_num_explicit_pages 00167 // Access: Published 00168 // Description: Returns the current number of explicitly-loaded 00169 // ConfigPages in the world. These represent pages that 00170 // were loaded dynamically at runtime by explicit calls 00171 // to ConfigPageManager::make_explicit_page(). 00172 //////////////////////////////////////////////////////////////////// 00173 INLINE int ConfigPageManager:: 00174 get_num_explicit_pages() const { 00175 return _explicit_pages.size(); 00176 } 00177 00178 //////////////////////////////////////////////////////////////////// 00179 // Function: ConfigPageManager::get_explicit_page 00180 // Access: Published 00181 // Description: Returns the nth explicit ConfigPage in the world. 00182 // See get_num_explicit_pages(). 00183 //////////////////////////////////////////////////////////////////// 00184 INLINE ConfigPage *ConfigPageManager:: 00185 get_explicit_page(int n) const { 00186 check_sort_pages(); 00187 nassertr(n >= 0 && n < (int)_explicit_pages.size(), (ConfigPage *)NULL); 00188 return _explicit_pages[n]; 00189 } 00190 00191 00192 //////////////////////////////////////////////////////////////////// 00193 // Function: ConfigPageManager::mark_unsorted() 00194 // Access: Public 00195 // Description: This method is meant to be used internally to this 00196 // module; there is no need to call it directly. It 00197 // indicates that the sort values of some pages may have 00198 // changed and pages need to be re-sorted. 00199 //////////////////////////////////////////////////////////////////// 00200 INLINE void ConfigPageManager:: 00201 mark_unsorted() { 00202 _pages_sorted = false; 00203 } 00204 00205 //////////////////////////////////////////////////////////////////// 00206 // Function: ConfigPageManager::check_sort_pages() 00207 // Access: Private 00208 // Description: Called internally to ensure that the list of 00209 // pages is properly sorted. 00210 //////////////////////////////////////////////////////////////////// 00211 INLINE void ConfigPageManager:: 00212 check_sort_pages() const { 00213 if (!_pages_sorted) { 00214 ((ConfigPageManager *)this)->sort_pages(); 00215 } 00216 } 00217 00218 INLINE ostream & 00219 operator << (ostream &out, const ConfigPageManager &pageMgr) { 00220 pageMgr.output(out); 00221 return out; 00222 }