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
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:
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
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
82INLINE std::ostream &operator << (std::ostream &out, const ConfigVariableManager &variableMgr);
83
84#include "configVariableManager.I"
85
86#endif
ConfigVariableCore
The internal definition of a ConfigVariable.
Definition configVariableCore.h:34
ConfigVariableManager
A global object that maintains the set of ConfigVariables (actually, ConfigVariableCores) everywhere ...
Definition configVariableManager.h:31
ConfigVariableManager::is_variable_used
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.
Definition configVariableManager.cxx:174
ConfigVariableManager::get_num_variables
get_num_variables
Returns the current number of active ConfigVariableCores in the world.
Definition configVariableManager.h:47
ConfigVariableManager::list_unused_variables
void list_unused_variables() const
Writes a list of all the variables that have been defined in a prc file without having been declared ...
Definition configVariableManager.cxx:247
ConfigVariableManager::get_variable_name
std::string get_variable_name(size_t n) const
Returns the name of the nth active ConfigVariable in the list.
Definition configVariableManager.cxx:162
ConfigVariableManager::make_variable_template
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...
Definition configVariableManager.cxx:101
ConfigVariableManager::write_prc_variables
void write_prc_variables(std::ostream &out) const
Writes all of the prc-set config variables, as they appear in a prc file somewhere,...
Definition configVariableManager.cxx:216
ConfigVariableManager::get_variable
get_variable
Returns the nth active ConfigVariableCore in the world.
Definition configVariableManager.h:47
ConfigVariableManager::list_variables
void list_variables() const
Writes a list of all the variables that have been declared somewhere in code, along with a brief desc...
Definition configVariableManager.cxx:269
ConfigVariableManager::list_dynamic_variables
void list_dynamic_variables() const
Writes a list of all the "dynamic" variables that have been declared somewhere in code,...
Definition configVariableManager.cxx:288
ConfigVariableManager::make_variable
ConfigVariableCore * make_variable(const std::string &name)
Creates and returns a new, undefined ConfigVariableCore with the indicated name; or if a variable wit...
Definition configVariableManager.cxx:50
configFlags.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
configVariableManager.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
dtoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
globPattern.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pnotify.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.