Panda3D

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
40 PUBLISHED:
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
125 INLINE 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
ConfigVariableManager
A global object that maintains the set of ConfigVariables (actually, ConfigVariableCores) everywhere ...
Definition: configVariableManager.h:31
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.