Colobot
CBotVarFloat.h
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
20 #pragma once
21 
22 #include "CBot/CBotVar/CBotVar.h"
23 
24 namespace CBot
25 {
26 
30 class CBotVarFloat : public CBotVar
31 {
32 public:
36  CBotVarFloat(const CBotToken& name);
37 
38  void SetValInt(int val, const std::string& s = nullptr) override;
39  void SetValFloat(float val) override;
40  int GetValInt() override;
41  float GetValFloat() override;
42  std::string GetValString() override;
43 
44  void Copy(CBotVar* pSrc, bool bName = true) override;
45 
46  void Add(CBotVar* left, CBotVar* right) override;
47  void Sub(CBotVar* left, CBotVar* right) override;
48  void Mul(CBotVar* left, CBotVar* right) override;
49  CBotError Div(CBotVar* left, CBotVar* right) override;
50  CBotError Modulo(CBotVar* left, CBotVar* right) override;
51  void Power(CBotVar* left, CBotVar* right) override;
52 
53  bool Lo(CBotVar* left, CBotVar* right) override;
54  bool Hi(CBotVar* left, CBotVar* right) override;
55  bool Ls(CBotVar* left, CBotVar* right) override;
56  bool Hs(CBotVar* left, CBotVar* right) override;
57  bool Eq(CBotVar* left, CBotVar* right) override;
58  bool Ne(CBotVar* left, CBotVar* right) override;
59 
60  void Neg() override;
61  void Inc() override;
62  void Dec() override;
63 
64  bool Save1State(FILE* pf) override;
65 
66 private:
68  float m_val;
69 };
70 
71 } // namespace CBot
CBotError Div(CBotVar *left, CBotVar *right) override
Division.
Definition: CBotVarFloat.cpp:129
float GetValFloat() override
Get value as float.
Definition: CBotVarFloat.cpp:88
void SetValInt(int val, const std::string &s=nullptr) override
Set value as an integer.
Definition: CBotVarFloat.cpp:68
bool Hi(CBotVar *left, CBotVar *right) override
left > right
Definition: CBotVarFloat.cpp:191
void Sub(CBotVar *left, CBotVar *right) override
Subtraction.
Definition: CBotVarFloat.cpp:160
CBotVarFloat(const CBotToken &name)
Constructor. Do not call directly, use CBotVar::Create()
Definition: CBotVarFloat.cpp:33
int GetValInt() override
Get value as integer.
Definition: CBotVarFloat.cpp:82
void Copy(CBotVar *pSrc, bool bName=true) override
Copy from another variable.
Definition: CBotVarFloat.cpp:50
bool Hs(CBotVar *left, CBotVar *right) override
left >= right
Definition: CBotVarFloat.cpp:203
void Add(CBotVar *left, CBotVar *right) override
Addition.
Definition: CBotVarFloat.cpp:153
A CBot variable.
Definition: CBotVar.h:42
bool Ne(CBotVar *left, CBotVar *right) override
left != right
Definition: CBotVarFloat.cpp:215
void Neg() override
-this
Definition: CBotVarFloat.cpp:167
CBotError
This enum contains possible CBot error values. Values in range 5000-5999 are compile errors...
Definition: CBotEnums.h:190
void Mul(CBotVar *left, CBotVar *right) override
Multiplication.
Definition: CBotVarFloat.cpp:115
bool Lo(CBotVar *left, CBotVar *right) override
left < right
Definition: CBotVarFloat.cpp:185
std::string GetValString() override
Get value as string.
Definition: CBotVarFloat.cpp:94
void Inc() override
++this
Definition: CBotVarFloat.cpp:173
CBotError Modulo(CBotVar *left, CBotVar *right) override
Modulo (remainder of division)
Definition: CBotVarFloat.cpp:141
bool Eq(CBotVar *left, CBotVar *right) override
left == right
Definition: CBotVarFloat.cpp:209
CBotVar subclass for managing float values (CBotTypFloat)
Definition: CBotVarFloat.h:30
void SetValFloat(float val) override
Set value as float.
Definition: CBotVarFloat.cpp:75
void Dec() override
–this
Definition: CBotVarFloat.cpp:179
bool Ls(CBotVar *left, CBotVar *right) override
left <= right
Definition: CBotVarFloat.cpp:197
CBot engine.
Definition: CBotCallMethode.cpp:28
bool Save1State(FILE *pf) override
Save variable data.
Definition: CBotVarFloat.cpp:221
void Power(CBotVar *left, CBotVar *right) override
Power.
Definition: CBotVarFloat.cpp:122
Class representing one token of a program.
Definition: CBotToken.h:80