Panda3D

Loading...
Searching...
No Matches
configVariableBool.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 configVariableBool.I
10 * @author drose
11 * @date 2004-10-20
12 */
13
14/**
15 *
16 */
17INLINE ConfigVariableBool::
18ConfigVariableBool(const std::string &name) :
19 ConfigVariable(name, VT_bool),
20 _local_modified(initial_invalid_cache())
21{
22 _core->set_used();
23}
24
25/**
26 *
27 */
28INLINE ConfigVariableBool::
29ConfigVariableBool(const std::string &name, bool default_value,
30 const std::string &description, int flags) :
31#ifdef PRC_SAVE_DESCRIPTIONS
32 ConfigVariable(name, VT_bool, description, flags),
33#else
34 ConfigVariable(name, VT_bool, std::string(), flags),
35#endif
36 _local_modified(initial_invalid_cache())
37{
38 _core->set_default_value(default_value ? "1" : "0");
39 _core->set_used();
40}
41
42/**
43 *
44 */
45INLINE ConfigVariableBool::
46ConfigVariableBool(const std::string &name, const std::string &default_value,
47 const std::string &description, int flags) :
48#ifdef PRC_SAVE_DESCRIPTIONS
49 ConfigVariable(name, VT_bool, description, flags),
50#else
51 ConfigVariable(name, VT_bool, std::string(), flags),
52#endif
53 _local_modified(initial_invalid_cache())
54{
55 _core->set_default_value(default_value);
56 _core->set_used();
57}
58
59/**
60 * Reassigns the variable's local value.
61 */
62INLINE void ConfigVariableBool::
63 operator = (bool value) {
64 set_value(value);
65}
66
67/**
68 * Returns the variable's value.
69 */
70ALWAYS_INLINE ConfigVariableBool::
71operator bool () const {
72 return get_value();
73}
74
75/**
76 * Returns the number of unique words in the variable.
77 */
78INLINE size_t ConfigVariableBool::
79 size() const {
80 return get_num_words();
81}
82
83/**
84 * Returns the value of the variable's nth word.
85 */
86INLINE bool ConfigVariableBool::
87 operator [] (size_t n) const {
88 return get_word(n);
89}
90
91/**
92 * Reassigns the variable's local value.
93 */
94INLINE void ConfigVariableBool::
95 set_value(bool value) {
96 set_string_value("");
97 set_bool_word(0, value);
98}
99
100/**
101 * Returns the variable's value.
102 */
103ALWAYS_INLINE bool ConfigVariableBool::
104 get_value() const {
105 TAU_PROFILE("bool ConfigVariableBool::get_value() const", " ", TAU_USER);
106 if (!is_cache_valid(_local_modified)) {
107 reload_value();
108 }
109 return _cache;
110}
111
112/**
113 * Returns the variable's default value.
114 */
115INLINE bool ConfigVariableBool::
116 get_default_value() const {
117 const ConfigDeclaration *decl = ConfigVariable::get_default_value();
118 if (decl != nullptr) {
119 return decl->get_bool_word(0);
120 }
121 return false;
122}
123
124/**
125 * Returns the variable's nth value.
126 */
127INLINE bool ConfigVariableBool::
128 get_word(size_t n) const {
129 return get_bool_word(n);
130}
131
132/**
133 * Reassigns the variable's nth value. This makes a local copy of the
134 * variable's overall value.
135 */
136INLINE void ConfigVariableBool::
137 set_word(size_t n, bool value) {
138 set_bool_word(n, value);
139}
ConfigDeclaration::get_bool_word
bool get_bool_word(size_t n) const
Returns the boolean value of the nth word of the declaration's value, or false if there is no nth val...
Definition configDeclaration.I:161
ConfigVariableBool::get_value
get_value
Returns the variable's value.
Definition configVariableBool.h:40
ConfigVariableBool::size
size_t size() const
Returns the number of unique words in the variable.
Definition configVariableBool.I:79
ConfigVariableBool::set_value
set_value
Reassigns the variable's local value.
Definition configVariableBool.h:40
ConfigVariableBool::get_default_value
get_default_value
Returns the variable's default value.
Definition configVariableBool.h:41
ConfigVariableBool::set_word
void set_word(size_t n, bool value)
Reassigns the variable's nth value.
Definition configVariableBool.I:137
ConfigVariableBool::get_word
bool get_word(size_t n) const
Returns the variable's nth value.
Definition configVariableBool.I:128
ConfigVariableBool::operator=
void operator=(bool value)
Reassigns the variable's local value.
Definition configVariableBool.I:63
ConfigVariableBool::operator[]
bool operator[](size_t n) const
Returns the value of the variable's nth word.
Definition configVariableBool.I:87
ConfigVariable
This is a generic, untyped ConfigVariable.
Definition configVariable.h:31
ConfigVariable::get_num_words
size_t get_num_words() const
Returns the number of words in the variable's value.
Definition configVariable.I:100
ConfigVariable::set_string_value
void set_string_value(const std::string &value)
Changes the value assigned to this variable.
Definition configVariable.I:80
string
STL class.
std
STL namespace.