Panda3D
configVariableManager.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 configVariableManager.h
10  * @author drose
11  * @date 2004-10-15
12  */
13 
14 #ifndef CONFIGVARIABLEMANAGER_H
15 #define CONFIGVARIABLEMANAGER_H
16 
17 #include "dtoolbase.h"
18 #include "configFlags.h"
19 #include "pnotify.h"
20 #include "globPattern.h"
21 #include <vector>
22 #include <map>
23 
24 class ConfigVariableCore;
25 
26 /**
27  * A global object that maintains the set of ConfigVariables (actually,
28  * ConfigVariableCores) everywhere in the world, and keeps them in sorted
29  * order.
30  */
31 class EXPCL_DTOOL_PRC ConfigVariableManager {
32 protected:
35 
36 PUBLISHED:
37  ConfigVariableCore *make_variable(const std::string &name);
38  ConfigVariableCore *make_variable_template(const std::string &pattern,
39  ConfigFlags::ValueType type,
40  const std::string &default_value,
41  const std::string &description = std::string(),
42  int flags = 0);
43 
44 
45  INLINE size_t get_num_variables() const;
46  INLINE ConfigVariableCore *get_variable(size_t n) const;
47  MAKE_SEQ(get_variables, get_num_variables, get_variable);
48  std::string get_variable_name(size_t n) const;
49  bool is_variable_used(size_t n) const;
50 
51  MAKE_SEQ_PROPERTY(variables, get_num_variables, get_variable);
52 
53  void output(std::ostream &out) const;
54  void write(std::ostream &out) const;
55 
56  void write_prc_variables(std::ostream &out) const;
57 
58  void list_unused_variables() const;
59  void list_variables() const;
60  void list_dynamic_variables() const;
61 
62  static ConfigVariableManager *get_global_ptr();
63 
64 private:
65  void list_variable(const ConfigVariableCore *variable,
66  bool include_descriptions) const;
67 
68  // We have to avoid pmap and pvector, due to the very low-level nature of
69  // this stuff.
70  typedef std::vector<ConfigVariableCore *> Variables;
71  Variables _variables;
72 
73  typedef std::map<std::string, ConfigVariableCore *> VariablesByName;
74  VariablesByName _variables_by_name;
75 
76  typedef std::map<GlobPattern, ConfigVariableCore *> VariableTemplates;
77  VariableTemplates _variable_templates;
78 
79  static ConfigVariableManager *_global_ptr;
80 };
81 
82 INLINE std::ostream &operator << (std::ostream &out, const ConfigVariableManager &variableMgr);
83 
84 #include "configVariableManager.I"
85 
86 #endif
The internal definition of a ConfigVariable.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A global object that maintains the set of ConfigVariables (actually, ConfigVariableCores) everywhere ...
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.