Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/util/multi_type.h @ 5539

Last change on this file since 5539 was 5539, checked in by bensch, 19 years ago

orxonox/trunk: some minor typo's in the MultiType class

File size: 1.4 KB
Line 
1/*!
2 * @file multi_type.h
3 * @brief Definition of ...
4*/
5
6#ifndef _MULTI_TYPE_H
7#define _MULTI_TYPE_H
8
9// FORWARD DECLARATION
10
11//! An enumerator defining Types, that can be stored inside a MultiType.
12typedef enum
13{
14  MT_NULL            = 0,                  //!< No Value at all.
15  MT_BOOL            = 1,                  //!< A bool Value.
16  MT_INT             = 2,                  //!< An int Value.
17  MT_FLOAT           = 4,                  //!< A float Value.
18  MT_CHAR            = 8,                  //!< A single char.
19  MT_STRING          = 16,                 //!< An entire String.
20
21} MT_Type;
22
23
24
25//! A class that encapsulates multiple differen types.
26/**
27 * Only one Value can be Stored inside this Class, but it can have any type: @see MT_Type.
28 */
29class MultiType {
30
31 public:
32   MultiType(bool value);
33   MultiType(int value);
34   MultiType(double value);
35   MultiType(char value);
36   MultiType(const char* value);
37   virtual ~MultiType();
38   void init();
39
40
41  /** @returns the Type of the Value stored in this MultiType */
42  inline MT_Type getType() const { return this->type; };
43
44  bool getBool();
45  int getInt();
46  float getFloat();
47  char getChar();
48  const char* getString();
49
50
51 private:
52   MT_Type             type;
53   union Type
54   {
55     bool             Bool;
56     int              Int;
57     float            Float;
58     char             Char;
59     char*            String;
60   } value;
61
62   char* storedString;
63};
64
65#endif /* _MULTI_TYPE_H */
Note: See TracBrowser for help on using the repository browser.