Panda3D
Loading...
Searching...
No Matches
configVariableBase.I
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 configVariableBase.I
10 * @author drose
11 * @date 2004-10-21
12 */
13
14/**
15 * This constructor is only intended to be called from a specialized
16 * ConfigVariableFoo derived class.
17 */
18INLINE ConfigVariableBase::
19ConfigVariableBase(const std::string &name,
20 ConfigVariableBase::ValueType value_type) :
21 _core(ConfigVariableManager::get_global_ptr()->make_variable(name))
22{
23 if (value_type != VT_undefined) {
24 _core->set_value_type(value_type);
25 }
26}
27
28/**
29 *
30 */
31INLINE ConfigVariableBase::
32~ConfigVariableBase() {
33}
34
35/**
36 * Returns the name of the variable.
37 */
38INLINE const std::string &ConfigVariableBase::
39get_name() const {
40 nassertr(_core != nullptr, *new std::string());
41 return _core->get_name();
42}
43
44/**
45 * Returns the stated type of this variable. This should be VT_list, unless a
46 * later variable declaration has changed it.
47 */
48INLINE ConfigVariableBase::ValueType ConfigVariableBase::
49get_value_type() const {
50 nassertr(_core != nullptr, VT_undefined);
51 return _core->get_value_type();
52}
53
54/**
55 * Returns the brief description of this variable, if it has been defined.
56 */
57INLINE const std::string &ConfigVariableBase::
58get_description() const {
59 nassertr(_core != nullptr, *new std::string());
60 return _core->get_description();
61}
62
63/**
64 * Returns the flags value as set by set_flags(). This includes the trust
65 * level and some other settings. See the individual methods is_closed(),
66 * get_trust_level(), etc. to pull out the semantic meaning of these flags
67 * individually.
68 */
70get_flags() const {
71 nassertr(_core != nullptr, 0);
72 return _core->get_flags();
73}
74
75/**
76 * Returns true if the variable is not trusted by any prc file (and hence
77 * cannot be modified from its compiled-in default value), or false for the
78 * normal case, in which the variable can be modified by any prc file at or
79 * above its trust level (see get_trust_level()).
80 *
81 * This value only has effect in a release build (specifically, when
82 * PRC_RESPECT_TRUST_LEVEL is defined true in Config.pp).
83 */
84INLINE bool ConfigVariableBase::
85is_closed() const {
86 nassertr(_core != nullptr, false);
87 return _core->is_closed();
88}
89
90/**
91 * Returns the minimum trust_level a prc file must demonstrate in order to
92 * redefine the value for this variable. Arguably, this should be called the
93 * "mistrust level", since the larger the value, the more suspicious we are of
94 * prc files. This value is not used if is_closed() returns true, which
95 * indicates no file may be trusted.
96 *
97 * This value only has effect in a release build (specifically, when
98 * PRC_RESPECT_TRUST_LEVEL is defined true in Config.pp).
99 */
100INLINE int ConfigVariableBase::
101get_trust_level() const {
102 nassertr(_core != nullptr, 0);
103 return _core->get_trust_level();
104}
105
106/**
107 * Returns true if the variable was indicated as "dynamic" by its constructor,
108 * indicating that its name was dynamically generated, possibly from a large
109 * pool, and it should not be listed along with the other variables.
110 */
111INLINE bool ConfigVariableBase::
112is_dynamic() const {
113 nassertr(_core != nullptr, false);
114 return _core->is_dynamic();
115}
116
117/**
118 * Removes the local value defined for this variable, and allows its value to
119 * be once again retrieved from the .prc files.
120 *
121 * Returns true if the value was successfully removed, false if it did not
122 * exist in the first place.
123 */
126 nassertr(_core != nullptr, false);
127 return _core->clear_local_value();
128}
129
130/**
131 * Returns true if this variable's value has been shadowed by a local
132 * assignment (as created via make_local_value()), or false otherwise.
133 */
135has_local_value() const {
136 nassertr(_core != nullptr, false);
137 return _core->has_local_value();
138}
139
140/**
141 * Returns true if this variable has an explicit value, either from a prc file
142 * or locally set, or false if variable has its default value.
143 */
145has_value() const {
146 nassertr(_core != nullptr, false);
147 return _core->has_value();
148}
149
150/**
151 *
152 */
153INLINE void ConfigVariableBase::
154output(std::ostream &out) const {
155 nassertv(_core != nullptr);
156 _core->output(out);
157}
158
159/**
160 *
161 */
162INLINE void ConfigVariableBase::
163write(std::ostream &out) const {
164 nassertv(_core != nullptr);
165 _core->write(out);
166}
167
168INLINE std::ostream &
169operator << (std::ostream &out, const ConfigVariableBase &variable) {
170 variable.output(out);
171 return out;
172}
This class is the base class for both ConfigVariableList and ConfigVariable (and hence for all of the...
get_name
Returns the name of the variable.
bool has_local_value() const
Returns true if this variable's value has been shadowed by a local assignment (as created via make_lo...
bool has_value() const
Returns true if this variable has an explicit value, either from a prc file or locally set,...
get_trust_level
Returns the minimum trust_level a prc file must demonstrate in order to redefine the value for this v...
int get_flags() const
Returns the flags value as set by set_flags().
is_dynamic
Returns true if the variable was indicated as "dynamic" by its constructor, indicating that its name ...
get_description
Returns the brief description of this variable, if it has been defined.
get_value_type
Returns the stated type of this variable.
is_closed
Returns true if the variable is not trusted by any prc file (and hence cannot be modified from its co...
bool clear_local_value()
Removes the local value defined for this variable, and allows its value to be once again retrieved fr...
bool has_local_value() const
Returns true if this variable's value has been shadowed by a local assignment (as created via make_lo...
get_value_type
Returns the stated type of this variable.
bool has_value() const
Returns true if this variable has an explicit value, either from a prc file or locally set,...
is_dynamic
Returns true if the variable was indicated as "dynamic" by its constructor, indicating that its name ...
bool clear_local_value()
Removes the local value defined for this variable, and allows its value to be once again retrieved fr...
int get_flags() const
Returns the flags value as set by set_flags().
is_closed
Returns true if the variable is not trusted by any prc file (and hence cannot be modified from its co...
get_description
Returns the brief description of this variable, if it has been defined.
get_name
Returns the name of the variable.
get_trust_level
Returns the minimum trust_level a prc file must demonstrate in order to redefine the value for this v...
A global object that maintains the set of ConfigVariables (actually, ConfigVariableCores) everywhere ...