Panda3D

Loading...
Searching...
No Matches
configVariableCore.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 configVariableCore.h
10 * @author drose
11 * @date 2004-10-15
12 */
13
14#ifndef CONFIGVARIABLECORE_H
15#define CONFIGVARIABLECORE_H
16
17#include "dtoolbase.h"
18#include "configFlags.h"
19#include "configPageManager.h"
20#include "pnotify.h"
21
22#include <vector>
23
24 class ConfigDeclaration;
25
26/**
27 * The internal definition of a ConfigVariable. This object is shared between
28 * all instances of a ConfigVariable that use the same variable name.
29 *
30 * You cannot create a ConfigVariableCore instance directly; instead, use the
31 * make() method, which may return a shared instance. Once created, these
32 * objects are never destructed.
33 */
34 class EXPCL_DTOOL_PRC ConfigVariableCore : public ConfigFlags {
35 private:
36 ConfigVariableCore(const std::string &name);
37 ConfigVariableCore(const ConfigVariableCore &templ, const std::string &name);
38 ~ConfigVariableCore();
39
40PUBLISHED:
41 INLINE const std::string &get_name() const;
42 INLINE bool is_used() const;
43
44 INLINE ValueType get_value_type() const;
45 INLINE const std::string &get_description() const;
46 INLINE int get_flags() const;
47 INLINE bool is_closed() const;
48 INLINE int get_trust_level() const;
49 INLINE bool is_dynamic() const;
50 INLINE const ConfigDeclaration *get_default_value() const;
51
52 void set_value_type(ValueType value_type);
53 void set_flags(int flags);
54 void set_description(const std::string &description);
55 void set_default_value(const std::string &default_value);
56 INLINE void set_used();
57
58 ConfigDeclaration *make_local_value();
59 bool clear_local_value();
60 INLINE bool has_local_value() const;
61
62 bool has_value() const;
63 size_t get_num_declarations() const;
64 const ConfigDeclaration *get_declaration(size_t n) const;
65 MAKE_SEQ(get_declarations, get_num_declarations, get_declaration);
66
67 INLINE size_t get_num_references() const;
68 INLINE const ConfigDeclaration *get_reference(size_t n) const;
69 MAKE_SEQ(get_references, get_num_references, get_reference);
70
71 INLINE size_t get_num_trusted_references() const;
72 INLINE const ConfigDeclaration *get_trusted_reference(size_t n) const;
73 MAKE_SEQ(get_trusted_references, get_num_trusted_references, get_trusted_reference);
74
75 INLINE size_t get_num_unique_references() const;
76 INLINE const ConfigDeclaration *get_unique_reference(size_t n) const;
77 MAKE_SEQ(get_unique_references, get_num_unique_references, get_unique_reference);
78 MAKE_SEQ_PROPERTY(declarations, get_num_declarations, get_declaration);
79
80 void output(std::ostream &out) const;
81 void write(std::ostream &out) const;
82
83 MAKE_PROPERTY(name, get_name);
84 MAKE_PROPERTY(used, is_used);
85 MAKE_PROPERTY(closed, is_closed);
86 MAKE_PROPERTY(trust_level, get_trust_level);
87 MAKE_PROPERTY(dynamic, is_dynamic);
88
89 MAKE_PROPERTY(value_type, get_value_type, set_value_type);
90 MAKE_PROPERTY(description, get_description, set_description);
91 MAKE_PROPERTY(default_value, get_default_value, set_default_value);
92
93 MAKE_SEQ_PROPERTY(references, get_num_references, get_reference);
94 MAKE_SEQ_PROPERTY(trusted_references, get_num_trusted_references, get_trusted_reference);
95 MAKE_SEQ_PROPERTY(unique_references, get_num_unique_references, get_unique_reference);
96
97 private:
98 void add_declaration(ConfigDeclaration *decl);
99 void remove_declaration(ConfigDeclaration *decl);
100
101 INLINE void check_sort_declarations() const;
102 void sort_declarations();
103
104 private:
105 std::string _name;
106 bool _is_used;
107 ValueType _value_type;
108 std::string _description;
109 int _flags;
110 ConfigDeclaration *_default_value;
111 ConfigDeclaration *_local_value;
112
113 typedef std::vector<const ConfigDeclaration *> Declarations;
114 Declarations _declarations;
115 Declarations _trusted_declarations;
116 Declarations _untrusted_declarations;
117 Declarations _unique_declarations;
118 bool _declarations_sorted;
119 bool _value_queried;
120
121 friend class ConfigDeclaration;
122 friend class ConfigVariableManager;
123};
124
125INLINE std::ostream &operator << (std::ostream &out, const ConfigVariableCore &variable);
126
127#include "configVariableCore.I"
128
129#endif
ConfigDeclaration
A single declaration of a config variable, typically defined as one line in a .prc file,...
Definition configDeclaration.h:34
ConfigFlags
This class is the base class of both ConfigVariable and ConfigVariableCore.
Definition configFlags.h:26
ConfigVariableCore
The internal definition of a ConfigVariable.
Definition configVariableCore.h:34
ConfigVariableCore::set_flags
void set_flags(int flags)
Specifies the trust level of this variable.
Definition configVariableCore.cxx:111
ConfigVariableCore::get_trusted_reference
get_trusted_reference
Returns the nth declaration in a trusted prc file that references this variable.
Definition configVariableCore.h:73
ConfigVariableCore::has_local_value
bool has_local_value() const
Returns true if this variable's value has been shadowed by a local assignment (as created via make_lo...
Definition configVariableCore.I:120
ConfigVariableCore::get_num_trusted_references
get_num_trusted_references
Returns the number of trusted prc files that reference this variable.
Definition configVariableCore.h:73
ConfigVariableCore::get_declaration
get_declaration
Returns the nth declarations that contributes to this variable's value.
Definition configVariableCore.h:65
ConfigVariableCore::get_unique_reference
get_unique_reference
Returns the nth trusted, unique value for this variable.
Definition configVariableCore.h:77
ConfigVariableCore::get_value_type
get_value_type
Returns the stated type of this variable.
Definition configVariableCore.h:89
ConfigVariableCore::set_default_value
set_default_value
Specifies the default value for this variable if it is not defined in any prc file.
Definition configVariableCore.h:91
ConfigVariableCore::get_default_value
get_default_value
Returns the default variable specified for this variable.
Definition configVariableCore.h:91
ConfigVariableCore::get_reference
get_reference
Returns the nth declaration in a prc file that references this variable.
Definition configVariableCore.h:69
ConfigVariableCore::has_value
bool has_value() const
Returns true if this variable has an explicit value, either from a prc file or locally set,...
Definition configVariableCore.cxx:273
ConfigVariableCore::is_dynamic
is_dynamic
Returns true if the variable was indicated as "dynamic" by its constructor, indicating that its name ...
Definition configVariableCore.h:87
ConfigVariableCore::set_used
void set_used()
Marks that the variable has been "declared" by a ConfigVariable.
Definition configVariableCore.I:111
ConfigVariableCore::set_description
set_description
Specifies the one-line description of this variable.
Definition configVariableCore.h:90
ConfigVariableCore::clear_local_value
bool clear_local_value()
Removes the local value defined for this variable, and allows its value to be once again retrieved fr...
Definition configVariableCore.cxx:257
ConfigVariableCore::get_flags
int get_flags() const
Returns the flags value as set by set_flags().
Definition configVariableCore.I:55
ConfigVariableCore::is_closed
is_closed
Returns true if the variable is not trusted by any prc file (and hence cannot be modified from its co...
Definition configVariableCore.h:85
ConfigVariableCore::get_num_references
get_num_references
Returns the number of prc files that reference this variable.
Definition configVariableCore.h:69
ConfigVariableCore::get_description
get_description
Returns the brief description of this variable, if it has been defined.
Definition configVariableCore.h:90
ConfigVariableCore::get_num_declarations
get_num_declarations
Returns the number of declarations that contribute to this variable's value.
Definition configVariableCore.h:65
ConfigVariableCore::get_name
get_name
Returns the name of the variable.
Definition configVariableCore.h:83
ConfigVariableCore::make_local_value
ConfigDeclaration * make_local_value()
Creates a new local value for this variable, if there is not already one specified.
Definition configVariableCore.cxx:232
ConfigVariableCore::get_trust_level
get_trust_level
Returns the minimum trust_level a prc file must demonstrate in order to redefine the value for this v...
Definition configVariableCore.h:86
ConfigVariableCore::get_num_unique_references
get_num_unique_references
Returns the number of trusted, unique (by string value) values there exist for this variable.
Definition configVariableCore.h:77
ConfigVariableCore::set_value_type
set_value_type
Specifies the type of this variable.
Definition configVariableCore.h:89
ConfigVariableCore::is_used
is_used
Returns true if the variable has been referenced by a ConfigVariable somewhere in code,...
Definition configVariableCore.h:84
value_type
configFlags.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
configPageManager.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
configVariableCore.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
dtoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pnotify.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.