ManaPlus
variabledata.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2010 The Mana Developers
4  * Copyright (C) 2011-2019 The ManaPlus Developers
5  * Copyright (C) 2019-2021 Andrei Karas
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef VARIABLEDATA_H
24 #define VARIABLEDATA_H
25 
26 #include <string>
27 
28 #include "localconsts.h"
29 
31 {
32  public:
33  enum DataType
34  {
35  DATA_NONE = 0,
39  DATA_BOOL
40  };
41 
43  { }
44 
46 
47  virtual ~VariableData()
48  {}
49 
50  virtual int getType() const A_WARN_UNUSED = 0;
51 };
52 
53 class IntData final : public VariableData
54 {
55  public:
56  explicit IntData(const int value) :
57  VariableData(),
58  mData(value)
59  { }
60 
62 
63  int getData() const noexcept2 A_WARN_UNUSED
64  { return mData; }
65 
67  { return DATA_INT; }
68 
69  private:
70  int mData;
71 };
72 
74 {
75  public:
76  explicit StringData(const std::string &value) :
77  VariableData(),
78  mData(value)
79  { }
80 
82 
83  const std::string &getData() const noexcept2 A_WARN_UNUSED
84  { return mData; }
85 
87  { return DATA_STRING; }
88 
89  private:
90  std::string mData;
91 };
92 
94 {
95  public:
96  explicit FloatData(const double value) :
97  VariableData(),
98  mData(value)
99  { }
100 
102 
103  double getData() const noexcept2 A_WARN_UNUSED
104  { return mData; }
105 
107  { return DATA_FLOAT; }
108 
109  private:
110  double mData;
111 };
112 
114 {
115  public:
116  explicit BoolData(const bool value) :
117  VariableData(),
118  mData(value)
119  { }
120 
122 
123  bool getData() const noexcept2 A_WARN_UNUSED
124  { return mData; }
125 
127  { return DATA_BOOL; }
128 
129  private:
130  bool mData;
131 };
132 
133 #endif // VARIABLEDATA_H
BoolData(const bool value)
Definition: variabledata.h:116
bool mData
Definition: variabledata.h:130
int getType() const
Definition: variabledata.h:126
FloatData(const double value)
Definition: variabledata.h:96
int getType() const
Definition: variabledata.h:106
double mData
Definition: variabledata.h:110
int getType() const
Definition: variabledata.h:66
int mData
Definition: variabledata.h:70
IntData(const int value)
Definition: variabledata.h:56
std::string mData
Definition: variabledata.h:90
StringData(const std::string &value)
Definition: variabledata.h:76
int getType() const
Definition: variabledata.h:86
virtual int getType() const =0
#define override
Definition: localconsts.h:47
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define notfinal
Definition: localconsts.h:261
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
PlayerInfoBackend mData
Definition: playerinfo.cpp:56