Panda3D
Loading...
Searching...
No Matches
configPageManager.h
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.h
10 * @author drose
11 * @date 2004-10-15
12 */
13
14#ifndef CONFIGPAGEMANAGER_H
15#define CONFIGPAGEMANAGER_H
16
17#include "dtoolbase.h"
18#include "configFlags.h"
19#include "dSearchPath.h"
20#include "globPattern.h"
21#include "pnotify.h"
22
23#include <vector>
24
25class ConfigPage;
26
27/**
28 * A global object that maintains the set of ConfigPages everywhere in the
29 * world, and keeps them in sorted order.
30 */
31class EXPCL_DTOOL_PRC ConfigPageManager : public ConfigFlags {
32protected:
35
36PUBLISHED:
37 INLINE bool loaded_implicit_pages() const;
38 INLINE void load_implicit_pages();
39 void reload_implicit_pages();
40
41 INLINE DSearchPath &get_search_path();
42
43 INLINE size_t get_num_prc_patterns() const;
44 INLINE std::string get_prc_pattern(size_t n) const;
45
46 INLINE size_t get_num_prc_encrypted_patterns() const;
47 INLINE std::string get_prc_encrypted_pattern(size_t n) const;
48
49 INLINE size_t get_num_prc_executable_patterns() const;
50 INLINE std::string get_prc_executable_pattern(size_t n) const;
51
52 ConfigPage *make_explicit_page(const std::string &name);
53 bool delete_explicit_page(ConfigPage *page);
54
55 INLINE size_t get_num_implicit_pages() const;
56 INLINE ConfigPage *get_implicit_page(size_t n) const;
57
58 INLINE size_t get_num_explicit_pages() const;
59 INLINE ConfigPage *get_explicit_page(size_t n) const;
60
61 void output(std::ostream &out) const;
62 void write(std::ostream &out) const;
63
64 static ConfigPageManager *get_global_ptr();
65
66PUBLISHED:
67 MAKE_PROPERTY(search_path, get_search_path);
68
69 MAKE_SEQ_PROPERTY(prc_patterns, get_num_prc_patterns, get_prc_pattern);
70 MAKE_SEQ_PROPERTY(prc_encrypted_patterns, get_num_prc_encrypted_patterns, get_prc_encrypted_pattern);
71 MAKE_SEQ_PROPERTY(prc_executable_patterns, get_num_prc_executable_patterns, get_prc_executable_pattern);
72
73 MAKE_SEQ_PROPERTY(implicit_pages, get_num_implicit_pages, get_implicit_page);
74 MAKE_SEQ_PROPERTY(explicit_pages, get_num_explicit_pages, get_explicit_page);
75
76public:
77 INLINE void mark_unsorted();
78
79private:
80 INLINE void check_sort_pages() const;
81 void sort_pages();
82
83 bool scan_auto_prc_dir(Filename &prc_dir) const;
84 bool scan_up_from(Filename &result, const Filename &dir,
85 const Filename &suffix) const;
86
87 void config_initialized();
88
89 typedef std::vector<ConfigPage *> Pages;
90 Pages _implicit_pages;
91 Pages _explicit_pages;
92 bool _pages_sorted;
93 int _next_page_seq;
94
95 bool _loaded_implicit;
96 bool _currently_loading;
97
98 DSearchPath _search_path;
99
100 typedef std::vector<GlobPattern> Globs;
101 Globs _prc_patterns;
102 Globs _prc_encrypted_patterns;
103 Globs _prc_executable_patterns;
104
105 // In load_implicit_pages(), we temporarily build up a list of potential
106 // config files to read andor execute. We'll need some data structures to
107 // store that information.
108 enum FileFlags {
109 FF_read = 0x001,
110 FF_execute = 0x002,
111 FF_decrypt = 0x004,
112 };
113 class ConfigFile {
114 public:
115 int _file_flags;
116 Filename _filename;
117 };
118 typedef std::vector<ConfigFile> ConfigFiles;
119
120 static ConfigPageManager *_global_ptr;
121};
122
123INLINE std::ostream &operator << (std::ostream &out, const ConfigPageManager &pageMgr);
124
125#include "configPageManager.I"
126
127#endif
This class is the base class of both ConfigVariable and ConfigVariableCore.
Definition configFlags.h:26
A global object that maintains the set of ConfigPages everywhere in the world, and keeps them in sort...
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
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.