Panda3D

configVariableBase.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 configVariableBase.h
10 * @author drose
11 * @date 2004-10-21
12 */
13
14 #ifndef CONFIGVARIABLEBASE_H
15 #define CONFIGVARIABLEBASE_H
16
17 #include "dtoolbase.h"
18 #include "configFlags.h"
19 #include "configVariableCore.h"
20 #include "configDeclaration.h"
21 #include "configVariableManager.h"
22 #include "vector_string.h"
23 #include "pset.h"
24
25 // Use this macro to wrap around a description passed to a ConfigVariable
26 // constructor. This allows the description to be completely compiled out, so
27 // that it won't even be a part of the string table, in the absence of
28 // PRC_SAVE_DESCRIPTIONS.
29 #ifdef PRC_SAVE_DESCRIPTIONS
30 #define PRC_DESC(description) description
31 #else
32 #define PRC_DESC(description) ""
33 #endif
34
35 /**
36 * This class is the base class for both ConfigVariableList and ConfigVariable
37 * (and hence for all of the ConfigVariableBool, ConfigVaribleString, etc.
38 * classes). It collects together the common interface for all generic
39 * ConfigVariables.
40 *
41 * Mostly, this class serves as a thin wrapper around ConfigVariableCore
42 * and/or ConfigDeclaration, more or less duplicating the interface presented
43 * there.
44 */
45 class EXPCL_DTOOL_PRC ConfigVariableBase : public ConfigFlags {
46 protected:
47 INLINE ConfigVariableBase(const std::string &name, ValueType type);
48 ConfigVariableBase(const std::string &name, ValueType type,
49 const std::string &description, int flags);
50 INLINE ~ConfigVariableBase();
51
52 PUBLISHED:
53 INLINE const std::string &get_name() const;
54
55 INLINE ValueType get_value_type() const;
56 INLINE const std::string &get_description() const;
57 INLINE int get_flags() const;
58 INLINE bool is_closed() const;
59 INLINE int get_trust_level() const;
60 INLINE bool is_dynamic() const;
61
62 MAKE_PROPERTY(name, get_name);
63 MAKE_PROPERTY(value_type, get_value_type);
64 MAKE_PROPERTY(description, get_description);
65 MAKE_PROPERTY(closed, is_closed);
66 MAKE_PROPERTY(trust_level, get_trust_level);
67 MAKE_PROPERTY(dynamic, is_dynamic);
68
69 INLINE bool clear_local_value();
70 INLINE bool has_local_value() const;
71 INLINE bool has_value() const;
72
73 INLINE void output(std::ostream &out) const;
74 INLINE void write(std::ostream &out) const;
75
76 protected:
77 void record_unconstructed() const;
78 bool was_unconstructed() const;
79
80 ConfigVariableCore *_core;
81
82 typedef pset<const ConfigVariableBase *> Unconstructed;
83 static Unconstructed *_unconstructed;
84 };
85
86 INLINE std::ostream &operator << (std::ostream &out, const ConfigVariableBase &variable);
87
88 #include "configVariableBase.I"
89
90 #endif
ConfigFlags
This class is the base class of both ConfigVariable and ConfigVariableCore.
Definition: configFlags.h:26
ConfigVariableBase
This class is the base class for both ConfigVariableList and ConfigVariable (and hence for all of the...
Definition: configVariableBase.h:45
ConfigVariableCore
The internal definition of a ConfigVariable.
Definition: configVariableCore.h:34
pset
This is our own Panda specialization on the default STL set.
Definition: pset.h:49
configDeclaration.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
configFlags.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
configVariableBase.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
configVariableCore.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
configVariableManager.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
dtoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pset.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
vector_string.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.