Panda3D
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 
25 class 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  */
31 class EXPCL_DTOOL_PRC ConfigPageManager : public ConfigFlags {
32 protected:
35 
36 PUBLISHED:
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 
66 public:
67  INLINE void mark_unsorted();
68 
69 private:
70  INLINE void check_sort_pages() const;
71  void sort_pages();
72 
73  bool scan_auto_prc_dir(Filename &prc_dir) const;
74  bool scan_up_from(Filename &result, const Filename &dir,
75  const Filename &suffix) const;
76 
77  void config_initialized();
78 
79  typedef std::vector<ConfigPage *> Pages;
80  Pages _implicit_pages;
81  Pages _explicit_pages;
82  bool _pages_sorted;
83  int _next_page_seq;
84 
85  bool _loaded_implicit;
86  bool _currently_loading;
87 
88  DSearchPath _search_path;
89 
90  typedef std::vector<GlobPattern> Globs;
91  Globs _prc_patterns;
92  Globs _prc_encrypted_patterns;
93  Globs _prc_executable_patterns;
94 
95  // In load_implicit_pages(), we temporarily build up a list of potential
96  // config files to read andor execute. We'll need some data structures to
97  // store that information.
98  enum FileFlags {
99  FF_read = 0x001,
100  FF_execute = 0x002,
101  FF_decrypt = 0x004,
102  };
103  class ConfigFile {
104  public:
105  int _file_flags;
106  Filename _filename;
107  };
108  typedef std::vector<ConfigFile> ConfigFiles;
109 
110  static ConfigPageManager *_global_ptr;
111 };
112 
113 INLINE std::ostream &operator << (std::ostream &out, const ConfigPageManager &pageMgr);
114 
115 #include "configPageManager.I"
116 
117 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A page of ConfigDeclarations that may be loaded or unloaded.
Definition: configPage.h:30
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class stores a list of directories that can be searched, in order, to locate a particular file.
Definition: dSearchPath.h:28
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.