Panda3D
 All Classes Functions Variables Enumerations
configVariableManager.h
1 // Filename: configVariableManager.h
2 // Created by: drose (15Oct04)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef CONFIGVARIABLEMANAGER_H
16 #define CONFIGVARIABLEMANAGER_H
17 
18 #include "dtoolbase.h"
19 #include "configFlags.h"
20 #include "pnotify.h"
21 #include "globPattern.h"
22 #include <vector>
23 #include <map>
24 
25 class ConfigVariableCore;
26 
27 ////////////////////////////////////////////////////////////////////
28 // Class : ConfigVariableManager
29 // Description : A global object that maintains the set of
30 // ConfigVariables (actually, ConfigVariableCores)
31 // everywhere in the world, and keeps them in sorted
32 // order.
33 ////////////////////////////////////////////////////////////////////
34 class EXPCL_DTOOLCONFIG ConfigVariableManager {
35 protected:
38 
39 PUBLISHED:
40  ConfigVariableCore *make_variable(const string &name);
41  ConfigVariableCore *make_variable_template(const string &pattern,
42  ConfigFlags::ValueType type,
43  const string &default_value,
44  const string &description = string(),
45  int flags = 0);
46 
47 
48  INLINE int get_num_variables() const;
49  INLINE ConfigVariableCore *get_variable(int n) const;
50  MAKE_SEQ(get_variables, get_num_variables, get_variable);
51  string get_variable_name(int n) const;
52  bool is_variable_used(int n) const;
53 
54  void output(ostream &out) const;
55  void write(ostream &out) const;
56 
57  void write_prc_variables(ostream &out) const;
58 
59  void list_unused_variables() const;
60  void list_variables() const;
61  void list_dynamic_variables() const;
62 
63  static ConfigVariableManager *get_global_ptr();
64 
65 private:
66  void list_variable(const ConfigVariableCore *variable,
67  bool include_descriptions) const;
68 
69  // We have to avoid pmap and pvector, due to the very low-level
70  // nature of this stuff.
71  typedef vector<ConfigVariableCore *> Variables;
72  Variables _variables;
73 
74  typedef map<string, ConfigVariableCore *> VariablesByName;
75  VariablesByName _variables_by_name;
76 
77  typedef map<GlobPattern, ConfigVariableCore *> VariableTemplates;
78  VariableTemplates _variable_templates;
79 
80  static ConfigVariableManager *_global_ptr;
81 };
82 
83 INLINE ostream &operator << (ostream &out, const ConfigVariableManager &variableMgr);
84 
85 #include "configVariableManager.I"
86 
87 #endif
88 
The internal definition of a ConfigVariable.
A global object that maintains the set of ConfigVariables (actually, ConfigVariableCores) everywhere ...