Panda3D
configVariableEnum.h
1 // Filename: configVariableEnum.h
2 // Created by: drose (21Oct04)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef CONFIGVARIABLEENUM_H
16 #define CONFIGVARIABLEENUM_H
17 
18 #include "dtoolbase.h"
19 #include "configVariable.h"
20 
21 ////////////////////////////////////////////////////////////////////
22 // Class : ConfigVariableEnum
23 // Description : This class specializes ConfigVariable as an
24 // enumerated type. It is a template class, so it
25 // cannot be easily published; it's not really necessary
26 // outside of C++ anyway.
27 //
28 // This variable assumes that the enumerated type in
29 // question has input and output stream operators
30 // defined that do the right thing (outputting a
31 // sensible string for the type, and converting a string
32 // to the correct value).
33 ////////////////////////////////////////////////////////////////////
34 template<class EnumType>
36 public:
37  INLINE ConfigVariableEnum(const string &name, EnumType default_value,
38  const string &description = string(),
39  int flags = 0);
40  INLINE ConfigVariableEnum(const string &name, const string &default_value,
41  const string &description = string(),
42  int flags = 0);
43  INLINE ~ConfigVariableEnum();
44 
45  INLINE void operator = (EnumType value);
46  INLINE operator EnumType () const;
47 
48  INLINE int size() const;
49  INLINE EnumType operator [] (int n) const;
50 
51  INLINE void set_value(EnumType value);
52  INLINE EnumType get_value() const;
53  INLINE EnumType get_default_value() const;
54 
55  INLINE EnumType get_word(int n) const;
56  INLINE void set_word(int n, EnumType value);
57 
58 private:
59  INLINE EnumType parse_string(const string &value) const;
60  INLINE string format_enum(EnumType value) const;
61 
62 private:
63  bool _got_default_value;
64  EnumType _default_value;
65 
66  AtomicAdjust::Integer _local_modified;
67  EnumType _cache;
68 };
69 
70 #include "configVariableEnum.I"
71 
72 #endif
73 
EnumType operator[](int n) const
Returns the value of the variable&#39;s nth word.
void operator=(EnumType value)
Reassigns the variable&#39;s local value.
EnumType get_default_value() const
Returns the variable&#39;s default value.
void set_word(int n, EnumType value)
Reassigns the variable&#39;s nth value.
EnumType get_word(int n) const
Returns the variable&#39;s nth value.
void set_value(EnumType value)
Reassigns the variable&#39;s local value.
This is a generic, untyped ConfigVariable.
This class specializes ConfigVariable as an enumerated type.
EnumType get_value() const
Returns the variable&#39;s value.
int size() const
Returns the number of unique words in the variable.