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 */
18INLINE bool ConfigPageManager::
19 loaded_implicit_pages() const {
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 */
29INLINE void ConfigPageManager::
30 load_implicit_pages() {
31 if (!_loaded_implicit) {
32 reload_implicit_pages();
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 */
42INLINE DSearchPath &ConfigPageManager::
43 get_search_path() {
44 load_implicit_pages();
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::
55 get_num_prc_patterns() const {
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::
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 */
74INLINE size_t ConfigPageManager::
75 get_num_prc_encrypted_patterns() const {
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::
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 */
94INLINE size_t ConfigPageManager::
95 get_num_prc_executable_patterns() const {
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::
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 */
114INLINE size_t ConfigPageManager::
115 get_num_implicit_pages() const {
116 return _implicit_pages.size();
117}
118
119/**
120 * Returns the nth implicit ConfigPage in the world. See
121 * get_num_implicit_pages().
122 */
123INLINE ConfigPage *ConfigPageManager::
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 */
135INLINE size_t ConfigPageManager::
136 get_num_explicit_pages() const {
137 return _explicit_pages.size();
138}
139
140/**
141 * Returns the nth explicit ConfigPage in the world. See
142 * get_num_explicit_pages().
143 */
144INLINE ConfigPage *ConfigPageManager::
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 */
157INLINE void ConfigPageManager::
158 mark_unsorted() {
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}
ConfigPageManager
A global object that maintains the set of ConfigPages everywhere in the world, and keeps them in sort...
Definition configPageManager.h:31
ConfigPageManager::mark_unsorted
void mark_unsorted()
This method is meant to be used internally to this module; there is no need to call it directly.
Definition configPageManager.I:158
ConfigPageManager::get_num_implicit_pages
get_num_implicit_pages
Returns the current number of implicitly-loaded ConfigPages in the world.
Definition configPageManager.h:73
ConfigPageManager::get_num_explicit_pages
get_num_explicit_pages
Returns the current number of explicitly-loaded ConfigPages in the world.
Definition configPageManager.h:74
ConfigPageManager::get_implicit_page
get_implicit_page
Returns the nth implicit ConfigPage in the world.
Definition configPageManager.h:73
ConfigPageManager::get_search_path
get_search_path
Returns the search path used to locate implicit .prc files.
Definition configPageManager.h:67
ConfigPageManager::get_prc_pattern
get_prc_pattern
Returns the nth filename pattern that will be considered a match as a valid config file.
Definition configPageManager.h:69
ConfigPageManager::get_explicit_page
get_explicit_page
Returns the nth explicit ConfigPage in the world.
Definition configPageManager.h:74
ConfigPageManager::get_num_prc_executable_patterns
get_num_prc_executable_patterns
Returns the number of patterns, like `*.exe`, that are compiled in that will be searched for as speci...
Definition configPageManager.h:71
ConfigPageManager::load_implicit_pages
void load_implicit_pages()
Searches the PRC_DIR and/or PRC_PATH directories for `*.prc` files and loads them in as pages.
Definition configPageManager.I:30
ConfigPageManager::get_prc_executable_pattern
get_prc_executable_pattern
Returns the nth filename pattern that will be considered a match as a valid executable-style config f...
Definition configPageManager.h:71
ConfigPageManager::loaded_implicit_pages
bool loaded_implicit_pages() const
Returns true if the implicit `*.prc` files have already been loaded, false otherwise.
Definition configPageManager.I:19
ConfigPageManager::get_num_prc_encrypted_patterns
get_num_prc_encrypted_patterns
Returns the number of patterns, like `*.pre`, that are compiled in that will be searched for as speci...
Definition configPageManager.h:70
ConfigPageManager::get_prc_encrypted_pattern
get_prc_encrypted_pattern
Returns the nth filename pattern that will be considered a match as a valid encrypted config file.
Definition configPageManager.h:70
ConfigPageManager::reload_implicit_pages
void reload_implicit_pages()
Searches the PRC_DIR and/or PRC_PATH directories for *.prc files and loads them in as pages.
Definition configPageManager.cxx:85
ConfigPageManager::get_num_prc_patterns
get_num_prc_patterns
Returns the number of patterns, like `*.prc`, that are compiled in that will be searched for as defau...
Definition configPageManager.h:69
ConfigPage
A page of ConfigDeclarations that may be loaded or unloaded.
Definition configPage.h:30
DSearchPath
This class stores a list of directories that can be searched, in order, to locate a particular file.
Definition dSearchPath.h:28