Panda3D
configPageManager.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file configPageManager.I
10  * @author drose
11  * @date 2004-10-15
12  */
13 
14 /**
15  * Returns true if the implicit *.prc files have already been loaded, false
16  * otherwise. Normally this will only be false briefly before startup.
17  */
18 INLINE bool ConfigPageManager::
20  return _loaded_implicit;
21 }
22 
23 /**
24  * Searches the PRC_DIR and/or PRC_PATH directories for *.prc files and loads
25  * them in as pages. This is normally called automatically at startup time,
26  * when the first variable's value is referenced. See also
27  * reload_implicit_pages().
28  */
29 INLINE void ConfigPageManager::
31  if (!_loaded_implicit) {
33  }
34 }
35 
36 /**
37  * Returns the search path used to locate implicit .prc files. This is
38  * determined by the PRC_DIR and PRC_PATH environment variables. The object
39  * returned by this method may be modified to change the path at runtime, and
40  * then reload_implicit_pages() called.
41  */
45  return _search_path;
46 }
47 
48 /**
49  * Returns the number of patterns, like "*.prc", that are compiled in that
50  * will be searched for as default config filenames. Normally there is only
51  * one pattern, and it is "*.prc", but others may be specified with the
52  * PRC_FILENAME variable in Config.pp.
53  */
54 INLINE size_t ConfigPageManager::
56  return _prc_patterns.size();
57 }
58 
59 /**
60  * Returns the nth filename pattern that will be considered a match as a valid
61  * config file. See get_num_prc_patterns().
62  */
63 INLINE std::string ConfigPageManager::
64 get_prc_pattern(size_t n) const {
65  nassertr(n < _prc_patterns.size(), std::string());
66  return _prc_patterns[n].get_pattern();
67 }
68 
69 /**
70  * Returns the number of patterns, like "*.pre", that are compiled in that
71  * will be searched for as special config files that are understood to be
72  * encrypted.
73  */
74 INLINE size_t ConfigPageManager::
76  return _prc_encrypted_patterns.size();
77 }
78 
79 /**
80  * Returns the nth filename pattern that will be considered a match as a valid
81  * encrypted config file. See get_num_prc_encrypted_patterns().
82  */
83 INLINE std::string ConfigPageManager::
84 get_prc_encrypted_pattern(size_t n) const {
85  nassertr(n < _prc_patterns.size(), std::string());
86  return _prc_encrypted_patterns[n].get_pattern();
87 }
88 
89 /**
90  * Returns the number of patterns, like "*.exe", that are compiled in that
91  * will be searched for as special config files that are to be executed as a
92  * program, and their output taken to be input. This is normally empty.
93  */
94 INLINE size_t ConfigPageManager::
96  return _prc_executable_patterns.size();
97 }
98 
99 /**
100  * Returns the nth filename pattern that will be considered a match as a valid
101  * executable-style config file. See get_num_prc_executable_patterns().
102  */
103 INLINE std::string ConfigPageManager::
104 get_prc_executable_pattern(size_t n) const {
105  nassertr(n < _prc_patterns.size(), std::string());
106  return _prc_executable_patterns[n].get_pattern();
107 }
108 
109 /**
110  * Returns the current number of implicitly-loaded ConfigPages in the world.
111  * These represent files that were automatically discovered on the disk as
112  * .prc files.
113  */
114 INLINE size_t ConfigPageManager::
116  return _implicit_pages.size();
117 }
118 
119 /**
120  * Returns the nth implicit ConfigPage in the world. See
121  * get_num_implicit_pages().
122  */
124 get_implicit_page(size_t n) const {
125  check_sort_pages();
126  nassertr(n < _implicit_pages.size(), nullptr);
127  return _implicit_pages[n];
128 }
129 
130 /**
131  * Returns the current number of explicitly-loaded ConfigPages in the world.
132  * These represent pages that were loaded dynamically at runtime by explicit
133  * calls to ConfigPageManager::make_explicit_page().
134  */
135 INLINE size_t ConfigPageManager::
137  return _explicit_pages.size();
138 }
139 
140 /**
141  * Returns the nth explicit ConfigPage in the world. See
142  * get_num_explicit_pages().
143  */
145 get_explicit_page(size_t n) const {
146  check_sort_pages();
147  nassertr(n < _explicit_pages.size(), nullptr);
148  return _explicit_pages[n];
149 }
150 
151 
152 /**
153  * This method is meant to be used internally to this module; there is no need
154  * to call it directly. It indicates that the sort values of some pages may
155  * have changed and pages need to be re-sorted.
156  */
157 INLINE void ConfigPageManager::
159  _pages_sorted = false;
160 }
161 
162 /**
163  * Called internally to ensure that the list of pages is properly sorted.
164  */
165 INLINE void ConfigPageManager::
166 check_sort_pages() const {
167  if (!_pages_sorted) {
168  ((ConfigPageManager *)this)->sort_pages();
169  }
170 }
171 
172 INLINE std::ostream &
173 operator << (std::ostream &out, const ConfigPageManager &pageMgr) {
174  pageMgr.output(out);
175  return out;
176 }
ConfigPage * get_explicit_page(size_t n) const
Returns the nth explicit ConfigPage in the world.
std::string get_prc_pattern(size_t n) const
Returns the nth filename pattern that will be considered a match as a valid config file.
size_t get_num_explicit_pages() const
Returns the current number of explicitly-loaded ConfigPages in the world.
void load_implicit_pages()
Searches the PRC_DIR and/or PRC_PATH directories for *.prc files and loads them in as pages.
std::string get_prc_encrypted_pattern(size_t n) const
Returns the nth filename pattern that will be considered a match as a valid encrypted config file.
size_t get_num_implicit_pages() const
Returns the current number of implicitly-loaded ConfigPages in the world.
A global object that maintains the set of ConfigPages everywhere in the world, and keeps them in sort...
bool loaded_implicit_pages() const
Returns true if the implicit *.prc files have already been loaded, false otherwise.
std::string get_prc_executable_pattern(size_t n) const
Returns the nth filename pattern that will be considered a match as a valid executable-style config f...
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.
A page of ConfigDeclarations that may be loaded or unloaded.
Definition: configPage.h:30
size_t get_num_prc_encrypted_patterns() const
Returns the number of patterns, like "*.pre", that are compiled in that will be searched for as speci...
ConfigPage * get_implicit_page(size_t n) const
Returns the nth implicit ConfigPage in the world.
This class stores a list of directories that can be searched, in order, to locate a particular file.
Definition: dSearchPath.h:28
size_t get_num_prc_patterns() const
Returns the number of patterns, like "*.prc", that are compiled in that will be searched for as defau...
size_t get_num_prc_executable_patterns() const
Returns the number of patterns, like "*.exe", that are compiled in that will be searched for as speci...
DSearchPath & get_search_path()
Returns the search path used to locate implicit .prc files.