Panda3D
|
00001 // Filename: configVariableManager.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 CONFIGVARIABLEMANAGER_H 00016 #define CONFIGVARIABLEMANAGER_H 00017 00018 #include "dtoolbase.h" 00019 #include "configFlags.h" 00020 #include "pnotify.h" 00021 #include "globPattern.h" 00022 #include <vector> 00023 #include <map> 00024 00025 class ConfigVariableCore; 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : ConfigVariableManager 00029 // Description : A global object that maintains the set of 00030 // ConfigVariables (actually, ConfigVariableCores) 00031 // everywhere in the world, and keeps them in sorted 00032 // order. 00033 //////////////////////////////////////////////////////////////////// 00034 class EXPCL_DTOOLCONFIG ConfigVariableManager { 00035 protected: 00036 ConfigVariableManager(); 00037 ~ConfigVariableManager(); 00038 00039 PUBLISHED: 00040 ConfigVariableCore *make_variable(const string &name); 00041 ConfigVariableCore *make_variable_template(const string &pattern, 00042 ConfigFlags::ValueType type, 00043 const string &default_value, 00044 const string &description = string(), 00045 int flags = 0); 00046 00047 00048 INLINE int get_num_variables() const; 00049 INLINE ConfigVariableCore *get_variable(int n) const; 00050 string get_variable_name(int n) const; 00051 bool is_variable_used(int n) const; 00052 00053 void output(ostream &out) const; 00054 void write(ostream &out) const; 00055 00056 void write_prc_variables(ostream &out) const; 00057 00058 void list_unused_variables() const; 00059 void list_variables() const; 00060 void list_dynamic_variables() const; 00061 00062 static ConfigVariableManager *get_global_ptr(); 00063 00064 private: 00065 void list_variable(const ConfigVariableCore *variable, 00066 bool include_descriptions) const; 00067 00068 // We have to avoid pmap and pvector, due to the very low-level 00069 // nature of this stuff. 00070 typedef vector<ConfigVariableCore *> Variables; 00071 Variables _variables; 00072 00073 typedef map<string, ConfigVariableCore *> VariablesByName; 00074 VariablesByName _variables_by_name; 00075 00076 typedef map<GlobPattern, ConfigVariableCore *> VariableTemplates; 00077 VariableTemplates _variable_templates; 00078 00079 static ConfigVariableManager *_global_ptr; 00080 }; 00081 00082 INLINE ostream &operator << (ostream &out, const ConfigVariableManager &variableMgr); 00083 00084 #include "configVariableManager.I" 00085 00086 #endif 00087