Panda3D
|
00001 // Filename: configPageManager.h 00002 // Created by: drose (15Oct04) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef CONFIGPAGEMANAGER_H 00016 #define CONFIGPAGEMANAGER_H 00017 00018 #include "dtoolbase.h" 00019 #include "configFlags.h" 00020 #include "dSearchPath.h" 00021 #include "globPattern.h" 00022 #include "pnotify.h" 00023 00024 #include <vector> 00025 00026 class ConfigPage; 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Class : ConfigPageManager 00030 // Description : A global object that maintains the set of ConfigPages 00031 // everywhere in the world, and keeps them in sorted 00032 // order. 00033 //////////////////////////////////////////////////////////////////// 00034 class EXPCL_DTOOLCONFIG ConfigPageManager : public ConfigFlags { 00035 protected: 00036 ConfigPageManager(); 00037 ~ConfigPageManager(); 00038 00039 PUBLISHED: 00040 INLINE bool loaded_implicit_pages() const; 00041 INLINE void load_implicit_pages(); 00042 void reload_implicit_pages(); 00043 00044 INLINE DSearchPath &get_search_path(); 00045 00046 INLINE int get_num_prc_patterns() const; 00047 INLINE string get_prc_pattern(int n) const; 00048 00049 INLINE int get_num_prc_encrypted_patterns() const; 00050 INLINE string get_prc_encrypted_pattern(int n) const; 00051 00052 INLINE int get_num_prc_executable_patterns() const; 00053 INLINE string get_prc_executable_pattern(int n) const; 00054 00055 ConfigPage *make_explicit_page(const string &name); 00056 bool delete_explicit_page(ConfigPage *page); 00057 00058 INLINE int get_num_implicit_pages() const; 00059 INLINE ConfigPage *get_implicit_page(int n) const; 00060 00061 INLINE int get_num_explicit_pages() const; 00062 INLINE ConfigPage *get_explicit_page(int n) const; 00063 00064 void output(ostream &out) const; 00065 void write(ostream &out) const; 00066 00067 static ConfigPageManager *get_global_ptr(); 00068 00069 public: 00070 INLINE void mark_unsorted(); 00071 00072 private: 00073 INLINE void check_sort_pages() const; 00074 void sort_pages(); 00075 00076 bool scan_auto_prc_dir(Filename &prc_dir) const; 00077 bool scan_up_from(Filename &result, const Filename &dir, 00078 const Filename &suffix) const; 00079 00080 void config_initialized(); 00081 00082 typedef vector<ConfigPage *> Pages; 00083 Pages _implicit_pages; 00084 Pages _explicit_pages; 00085 bool _pages_sorted; 00086 int _next_page_seq; 00087 00088 bool _loaded_implicit; 00089 bool _currently_loading; 00090 00091 DSearchPath _search_path; 00092 00093 typedef vector<GlobPattern> Globs; 00094 Globs _prc_patterns; 00095 Globs _prc_encrypted_patterns; 00096 Globs _prc_executable_patterns; 00097 00098 // In load_implicit_pages(), we temporarily build up a list of 00099 // potential config files to read and/or execute. We'll need some 00100 // data structures to store that information. 00101 enum FileFlags { 00102 FF_read = 0x001, 00103 FF_execute = 0x002, 00104 FF_decrypt = 0x004, 00105 }; 00106 class ConfigFile { 00107 public: 00108 int _file_flags; 00109 Filename _filename; 00110 }; 00111 typedef vector<ConfigFile> ConfigFiles; 00112 00113 static ConfigPageManager *_global_ptr; 00114 }; 00115 00116 INLINE ostream &operator << (ostream &out, const ConfigPageManager &pageMgr); 00117 00118 #include "configPageManager.I" 00119 00120 #endif