Panda3D
Loading...
Searching...
No Matches
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
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 */
31class EXPCL_DTOOL_PRC ConfigVariableManager {
32protected:
33 ConfigVariableManager();
34 ~ConfigVariableManager();
35
36PUBLISHED:
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
64private:
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
82INLINE std::ostream &operator << (std::ostream &out, const ConfigVariableManager &variableMgr);
83
85
86#endif
The internal definition of a ConfigVariable.
A global object that maintains the set of ConfigVariables (actually, ConfigVariableCores) everywhere ...
bool is_variable_used(size_t n) const
Returns true if the nth active ConfigVariable in the list has been used by code, false otherwise.
get_num_variables
Returns the current number of active ConfigVariableCores in the world.
void list_unused_variables() const
Writes a list of all the variables that have been defined in a prc file without having been declared ...
std::string get_variable_name(size_t n) const
Returns the name of the nth active ConfigVariable in the list.
ConfigVariableCore * make_variable_template(const std::string &pattern, ConfigFlags::ValueType type, const std::string &default_value, const std::string &description=std::string(), int flags=0)
Defines a variable "template" to match against dynamically-defined variables that may or may not be c...
void write_prc_variables(std::ostream &out) const
Writes all of the prc-set config variables, as they appear in a prc file somewhere,...
get_variable
Returns the nth active ConfigVariableCore in the world.
void list_variables() const
Writes a list of all the variables that have been declared somewhere in code, along with a brief desc...
void list_dynamic_variables() const
Writes a list of all the "dynamic" variables that have been declared somewhere in code,...
ConfigVariableCore * make_variable(const std::string &name)
Creates and returns a new, undefined ConfigVariableCore with the indicated name; or if a variable wit...
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.