Panda3D

Loading...
Searching...
No Matches
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
52PUBLISHED:
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
86INLINE 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
ConfigVariableBase::get_name
get_name
Returns the name of the variable.
Definition configVariableBase.h:62
ConfigVariableBase::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 configVariableBase.I:135
ConfigVariableBase::has_value
bool has_value() const
Returns true if this variable has an explicit value, either from a prc file or locally set,...
Definition configVariableBase.I:145
ConfigVariableBase::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 configVariableBase.h:66
ConfigVariableBase::get_flags
int get_flags() const
Returns the flags value as set by set_flags().
Definition configVariableBase.I:70
ConfigVariableBase::is_dynamic
is_dynamic
Returns true if the variable was indicated as "dynamic" by its constructor, indicating that its name ...
Definition configVariableBase.h:67
ConfigVariableBase::get_description
get_description
Returns the brief description of this variable, if it has been defined.
Definition configVariableBase.h:64
ConfigVariableBase::get_value_type
get_value_type
Returns the stated type of this variable.
Definition configVariableBase.h:63
ConfigVariableBase::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 configVariableBase.h:65
ConfigVariableBase::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 configVariableBase.I:125
ConfigVariableCore
The internal definition of a ConfigVariable.
Definition configVariableCore.h:34
value_type
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.