Panda3D
Loading...
Searching...
No Matches
configVariableEnum.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 configVariableEnum.h
10 * @author drose
11 * @date 2004-10-21
12 */
13
14#ifndef CONFIGVARIABLEENUM_H
15#define CONFIGVARIABLEENUM_H
16
17#include "dtoolbase.h"
18#include "configVariable.h"
19
20/**
21 * This class specializes ConfigVariable as an enumerated type. It is a
22 * template class, so it cannot be easily published; it's not really necessary
23 * outside of C++ anyway.
24 *
25 * This variable assumes that the enumerated type in question has input and
26 * output stream operators defined that do the right thing (outputting a
27 * sensible string for the type, and converting a string to the correct
28 * value).
29 */
30template<class EnumType>
31class ConfigVariableEnum : public ConfigVariable {
32public:
33 INLINE ConfigVariableEnum(const std::string &name, EnumType default_value,
34 const std::string &description = std::string(),
35 int flags = 0);
36 INLINE ConfigVariableEnum(const std::string &name, const std::string &default_value,
37 const std::string &description = std::string(),
38 int flags = 0);
39 INLINE ~ConfigVariableEnum();
40
41 INLINE void operator = (EnumType value);
42 INLINE operator EnumType () const;
43
44 INLINE size_t size() const;
45 INLINE EnumType operator [] (size_t n) const;
46
47 INLINE void set_value(EnumType value);
48 INLINE EnumType get_value() const;
49 INLINE EnumType get_default_value() const;
50 MAKE_PROPERTY(value, get_value, set_value);
51 MAKE_PROPERTY(default_value, get_default_value);
52
53 INLINE EnumType get_word(size_t n) const;
54 INLINE void set_word(size_t n, EnumType value);
55
56private:
57 INLINE EnumType parse_string(const std::string &value) const;
58 INLINE std::string format_enum(EnumType value) const;
59
60private:
61 bool _got_default_value;
62 EnumType _default_value;
63
64 AtomicAdjust::Integer _local_modified;
65 EnumType _cache;
66};
67
68#include "configVariableEnum.I"
69
70#endif
get_default_value
Returns the variable's default value.
set_value
Reassigns the variable's local value.
EnumType operator[](size_t n) const
Returns the value of the variable's nth word.
void operator=(EnumType value)
Reassigns the variable's local value.
void set_word(size_t n, EnumType value)
Reassigns the variable's nth value.
get_value
Returns the variable's value.
EnumType get_word(size_t n) const
Returns the variable's nth value.
size_t size() const
Returns the number of unique words in the variable.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.