Panda3D
 All Classes Functions Variables Enumerations
configPageManager.I
1 // Filename: configPageManager.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: ConfigPageManager::loaded_implicit_pages
18 // Access: Published
19 // Description: Returns true if the implicit *.prc files have already
20 // been loaded, false otherwise. Normally this will
21 // only be false briefly before startup.
22 ////////////////////////////////////////////////////////////////////
23 INLINE bool ConfigPageManager::
25  return _loaded_implicit;
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: ConfigPageManager::load_implicit_pages
30 // Access: Published
31 // Description: Searches the PRC_DIR and/or PRC_PATH directories for
32 // *.prc files and loads them in as pages. This is
33 // normally called automatically at startup time, when
34 // the first variable's value is referenced. See also
35 // reload_implicit_pages().
36 ////////////////////////////////////////////////////////////////////
37 INLINE void ConfigPageManager::
39  if (!_loaded_implicit) {
41  }
42 }
43 
44 ////////////////////////////////////////////////////////////////////
45 // Function: ConfigPageManager::get_search_path
46 // Access: Published
47 // Description: Returns the search path used to locate implicit .prc
48 // files. This is determined by the PRC_DIR and
49 // PRC_PATH environment variables. The object returned
50 // by this method may be modified to change the path at
51 // runtime, and then reload_implicit_pages() called.
52 ////////////////////////////////////////////////////////////////////
56  return _search_path;
57 }
58 
59 ////////////////////////////////////////////////////////////////////
60 // Function: ConfigPageManager::get_num_prc_patterns
61 // Access: Published
62 // Description: Returns the number of patterns, like "*.prc", that
63 // are compiled in that will be searched for as default
64 // config filenames. Normally there is only one
65 // pattern, and it is "*.prc", but others may be
66 // specified with the PRC_FILENAME variable in
67 // Config.pp.
68 ////////////////////////////////////////////////////////////////////
69 INLINE int ConfigPageManager::
71  return _prc_patterns.size();
72 }
73 
74 ////////////////////////////////////////////////////////////////////
75 // Function: ConfigPageManager::get_prc_pattern
76 // Access: Published
77 // Description: Returns the nth filename pattern that will be
78 // considered a match as a valid config file. See
79 // get_num_prc_patterns().
80 ////////////////////////////////////////////////////////////////////
81 INLINE string ConfigPageManager::
82 get_prc_pattern(int n) const {
83  nassertr(n >= 0 && n < (int)_prc_patterns.size(), string());
84  return _prc_patterns[n].get_pattern();
85 }
86 
87 ////////////////////////////////////////////////////////////////////
88 // Function: ConfigPageManager::get_num_prc_encrypted_patterns
89 // Access: Published
90 // Description: Returns the number of patterns, like "*.pre", that
91 // are compiled in that will be searched for as special
92 // config files that are understood to be encrypted.
93 ////////////////////////////////////////////////////////////////////
94 INLINE int ConfigPageManager::
96  return _prc_encrypted_patterns.size();
97 }
98 
99 ////////////////////////////////////////////////////////////////////
100 // Function: ConfigPageManager::get_prc_encrypted_pattern
101 // Access: Published
102 // Description: Returns the nth filename pattern that will be
103 // considered a match as a valid encrypted config
104 // file. See get_num_prc_encrypted_patterns().
105 ////////////////////////////////////////////////////////////////////
106 INLINE string ConfigPageManager::
108  nassertr(n >= 0 && n < (int)_prc_patterns.size(), string());
109  return _prc_encrypted_patterns[n].get_pattern();
110 }
111 
112 ////////////////////////////////////////////////////////////////////
113 // Function: ConfigPageManager::get_num_prc_executable_patterns
114 // Access: Published
115 // Description: Returns the number of patterns, like "*.exe", that
116 // are compiled in that will be searched for as special
117 // config files that are to be executed as a program,
118 // and their output taken to be input. This is normally
119 // empty.
120 ////////////////////////////////////////////////////////////////////
121 INLINE int ConfigPageManager::
123  return _prc_executable_patterns.size();
124 }
125 
126 ////////////////////////////////////////////////////////////////////
127 // Function: ConfigPageManager::get_prc_executable_pattern
128 // Access: Published
129 // Description: Returns the nth filename pattern that will be
130 // considered a match as a valid executable-style config
131 // file. See get_num_prc_executable_patterns().
132 ////////////////////////////////////////////////////////////////////
133 INLINE string ConfigPageManager::
135  nassertr(n >= 0 && n < (int)_prc_patterns.size(), string());
136  return _prc_executable_patterns[n].get_pattern();
137 }
138 
139 ////////////////////////////////////////////////////////////////////
140 // Function: ConfigPageManager::get_num_implicit_pages
141 // Access: Published
142 // Description: Returns the current number of implicitly-loaded
143 // ConfigPages in the world. These represent files that
144 // were automatically discovered on the disk as .prc
145 // files.
146 ////////////////////////////////////////////////////////////////////
147 INLINE int ConfigPageManager::
149  return _implicit_pages.size();
150 }
151 
152 ////////////////////////////////////////////////////////////////////
153 // Function: ConfigPageManager::get_implicit_page
154 // Access: Published
155 // Description: Returns the nth implicit ConfigPage in the world.
156 // See get_num_implicit_pages().
157 ////////////////////////////////////////////////////////////////////
159 get_implicit_page(int n) const {
160  check_sort_pages();
161  nassertr(n >= 0 && n < (int)_implicit_pages.size(), (ConfigPage *)NULL);
162  return _implicit_pages[n];
163 }
164 
165 ////////////////////////////////////////////////////////////////////
166 // Function: ConfigPageManager::get_num_explicit_pages
167 // Access: Published
168 // Description: Returns the current number of explicitly-loaded
169 // ConfigPages in the world. These represent pages that
170 // were loaded dynamically at runtime by explicit calls
171 // to ConfigPageManager::make_explicit_page().
172 ////////////////////////////////////////////////////////////////////
173 INLINE int ConfigPageManager::
175  return _explicit_pages.size();
176 }
177 
178 ////////////////////////////////////////////////////////////////////
179 // Function: ConfigPageManager::get_explicit_page
180 // Access: Published
181 // Description: Returns the nth explicit ConfigPage in the world.
182 // See get_num_explicit_pages().
183 ////////////////////////////////////////////////////////////////////
185 get_explicit_page(int n) const {
186  check_sort_pages();
187  nassertr(n >= 0 && n < (int)_explicit_pages.size(), (ConfigPage *)NULL);
188  return _explicit_pages[n];
189 }
190 
191 
192 ////////////////////////////////////////////////////////////////////
193 // Function: ConfigPageManager::mark_unsorted()
194 // Access: Public
195 // Description: This method is meant to be used internally to this
196 // module; there is no need to call it directly. It
197 // indicates that the sort values of some pages may have
198 // changed and pages need to be re-sorted.
199 ////////////////////////////////////////////////////////////////////
200 INLINE void ConfigPageManager::
202  _pages_sorted = false;
203 }
204 
205 ////////////////////////////////////////////////////////////////////
206 // Function: ConfigPageManager::check_sort_pages()
207 // Access: Private
208 // Description: Called internally to ensure that the list of
209 // pages is properly sorted.
210 ////////////////////////////////////////////////////////////////////
211 INLINE void ConfigPageManager::
212 check_sort_pages() const {
213  if (!_pages_sorted) {
214  ((ConfigPageManager *)this)->sort_pages();
215  }
216 }
217 
218 INLINE ostream &
219 operator << (ostream &out, const ConfigPageManager &pageMgr) {
220  pageMgr.output(out);
221  return out;
222 }
string get_prc_executable_pattern(int n) const
Returns the nth filename pattern that will be considered a match as a valid executable-style config f...
int get_num_prc_executable_patterns() const
Returns the number of patterns, like &quot;*.exe&quot;, that are compiled in that will be searched for as speci...
string get_prc_pattern(int n) const
Returns the nth filename pattern that will be considered a match as a valid config file...
void load_implicit_pages()
Searches the PRC_DIR and/or PRC_PATH directories for .prc files and loads them in as pages...
A global object that maintains the set of ConfigPages everywhere in the world, and keeps them in sort...
int get_num_implicit_pages() const
Returns the current number of implicitly-loaded ConfigPages in the world.
ConfigPage * get_implicit_page(int n) const
Returns the nth implicit ConfigPage in the world.
void reload_implicit_pages()
Searches the PRC_DIR and/or PRC_PATH directories for .prc files and loads them in as pages...
void mark_unsorted()
This method is meant to be used internally to this module; there is no need to call it directly...
bool loaded_implicit_pages() const
Returns true if the implicit *.prc files have already been loaded, false otherwise.
int get_num_explicit_pages() const
Returns the current number of explicitly-loaded ConfigPages in the world.
A page of ConfigDeclarations that may be loaded or unloaded.
Definition: configPage.h:33
ConfigPage * get_explicit_page(int n) const
Returns the nth explicit ConfigPage in the world.
int get_num_prc_patterns() const
Returns the number of patterns, like &quot;*.prc&quot;, that are compiled in that will be searched for as defau...
int get_num_prc_encrypted_patterns() const
Returns the number of patterns, like &quot;*.pre&quot;, that are compiled in that will be searched for as speci...
This class stores a list of directories that can be searched, in order, to locate a particular file...
Definition: dSearchPath.h:32
string get_prc_encrypted_pattern(int n) const
Returns the nth filename pattern that will be considered a match as a valid encrypted config file...
DSearchPath & get_search_path()
Returns the search path used to locate implicit .prc files.