Panda3D
configVariable.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 configVariable.h
10  * @author drose
11  * @date 2004-10-18
12  */
13 
14 #ifndef CONFIGVARIABLE_H
15 #define CONFIGVARIABLE_H
16 
17 #include "dtoolbase.h"
18 #include "configVariableBase.h"
19 #include "numeric_types.h"
20 
21 /**
22  * This is a generic, untyped ConfigVariable. It is also the base class for
23  * the typed ConfigVariables, and contains all of the code common to
24  * ConfigVariables of all types (except ConfigVariableList, which is a bit of
25  * a special case).
26  *
27  * Mostly, this class serves as a thin wrapper around ConfigVariableCore
28  * and/or ConfigDeclaration, more or less duplicating the interface presented
29  * there.
30  */
31 class EXPCL_DTOOL_PRC ConfigVariable : public ConfigVariableBase {
32 protected:
33  INLINE ConfigVariable(const std::string &name, ValueType type);
34  INLINE ConfigVariable(const std::string &name, ValueType type,
35  const std::string &description, int flags);
36 
37 PUBLISHED:
38  INLINE explicit ConfigVariable(const std::string &name);
39  INLINE ~ConfigVariable();
40 
41  INLINE const std::string &get_string_value() const;
42  INLINE void set_string_value(const std::string &value);
43  INLINE void clear_value();
44 
45  INLINE size_t get_num_words() const;
46 
47 protected:
48  INLINE const ConfigDeclaration *get_default_value() const;
49 
50  INLINE bool has_string_word(size_t n) const;
51  INLINE bool has_bool_word(size_t n) const;
52  INLINE bool has_int_word(size_t n) const;
53  INLINE bool has_int64_word(size_t n) const;
54  INLINE bool has_double_word(size_t n) const;
55 
56  INLINE std::string get_string_word(size_t n) const;
57  INLINE bool get_bool_word(size_t n) const;
58  INLINE int get_int_word(size_t n) const;
59  INLINE int64_t get_int64_word(size_t n) const;
60  INLINE double get_double_word(size_t n) const;
61 
62  INLINE void set_string_word(size_t n, const std::string &value);
63  INLINE void set_bool_word(size_t n, bool value);
64  INLINE void set_int_word(size_t n, int value);
65  INLINE void set_int64_word(size_t n, int64_t value);
66  INLINE void set_double_word(size_t n, double value);
67 
68 protected:
69  INLINE bool is_constructed() const;
70  void report_unconstructed() const;
71 };
72 
73 #include "configVariable.I"
74 
75 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a generic, untyped ConfigVariable.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class is the base class for both ConfigVariableList and ConfigVariable (and hence for all of the...
A single declaration of a config variable, typically defined as one line in a .prc file,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.