Panda3D
Loading...
Searching...
No Matches
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 */
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 */
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 */
54INLINE 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 */
63INLINE std::string ConfigPageManager::
64get_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 */
74INLINE 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 */
83INLINE std::string ConfigPageManager::
84get_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 */
94INLINE 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 */
103INLINE std::string ConfigPageManager::
104get_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 */
114INLINE 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 */
124get_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 */
135INLINE 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 */
145get_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 */
159 _pages_sorted = false;
160}
161
162/**
163 * Called internally to ensure that the list of pages is properly sorted.
164 */
165INLINE void ConfigPageManager::
166check_sort_pages() const {
167 if (!_pages_sorted) {
168 ((ConfigPageManager *)this)->sort_pages();
169 }
170}
171
172INLINE std::ostream &
173operator << (std::ostream &out, const ConfigPageManager &pageMgr) {
174 pageMgr.output(out);
175 return out;
176}
A global object that maintains the set of ConfigPages everywhere in the world, and keeps them in sort...
void mark_unsorted()
This method is meant to be used internally to this module; there is no need to call it directly.
get_num_implicit_pages
Returns the current number of implicitly-loaded ConfigPages in the world.
get_num_explicit_pages
Returns the current number of explicitly-loaded ConfigPages in the world.
get_implicit_page
Returns the nth implicit ConfigPage in the world.
get_search_path
Returns the search path used to locate implicit .prc files.
get_prc_pattern
Returns the nth filename pattern that will be considered a match as a valid config file.
get_explicit_page
Returns the nth explicit ConfigPage in the world.
get_num_prc_executable_patterns
Returns the number of patterns, like `*.exe`, that are compiled in that will be searched for as speci...
void load_implicit_pages()
Searches the PRC_DIR and/or PRC_PATH directories for `*.prc` files and loads them in as pages.
get_prc_executable_pattern
Returns the nth filename pattern that will be considered a match as a valid executable-style config f...
bool loaded_implicit_pages() const
Returns true if the implicit `*.prc` files have already been loaded, false otherwise.
get_num_prc_encrypted_patterns
Returns the number of patterns, like `*.pre`, that are compiled in that will be searched for as speci...
get_prc_encrypted_pattern
Returns the nth filename pattern that will be considered a match as a valid encrypted config file.
void reload_implicit_pages()
Searches the PRC_DIR and/or PRC_PATH directories for *.prc files and loads them in as pages.
get_num_prc_patterns
Returns the number of patterns, like `*.prc`, that are compiled in that will be searched for as defau...
A page of ConfigDeclarations that may be loaded or unloaded.
Definition configPage.h:30
This class stores a list of directories that can be searched, in order, to locate a particular file.
Definition dSearchPath.h:28