Colobot
CBotVarPointer.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 CBotVarPointer : public CBotVar
31 {
32 public:
36  CBotVarPointer(const CBotToken& name, CBotTypResult& type);
41 
42  void Copy(CBotVar* pSrc, bool bName = true) override;
43 
44  void SetClass(CBotClass* pClass) override;
45  CBotClass* GetClass() override;
46 
47  CBotVar* GetItem(const std::string& name) override;
48  CBotVar* GetItemRef(int nIdent) override;
49  CBotVar* GetItemList() override;
50  std::string GetValString() override;
51 
52  void SetPointer(CBotVar* p) override;
53  CBotVarClass* GetPointer() override;
54 
55  void SetIdent(long n) override;
60  long GetIdent();
61 
62  void ConstructorSet() override;
63 
64  bool Save1State(FILE* pf) override;
65 
66  void Update(void* pUser) override;
67 
68  bool Eq(CBotVar* left, CBotVar* right) override;
69  bool Ne(CBotVar* left, CBotVar* right) override;
70 
71 private:
73  CBotVarClass* m_pVarClass;
75  CBotClass* m_pClass;
76  friend class CBotVar;
77 };
78 
79 } // namespace CBot
void SetPointer(CBotVar *p) override
Set value for pointer types.
Definition: CBotVarPointer.cpp:110
void Copy(CBotVar *pSrc, bool bName=true) override
Copy from another variable.
Definition: CBotVarPointer.cpp:193
CBotVarClass * GetPointer() override
Get value for pointer types.
Definition: CBotVarPointer.cpp:138
void ConstructorSet() override
Called after constructor has been called.
Definition: CBotVarPointer.cpp:104
bool Ne(CBotVar *left, CBotVar *right) override
left != right
Definition: CBotVarPointer.cpp:233
void SetClass(CBotClass *pClass) override
Set class this variable is instance of.
Definition: CBotVarPointer.cpp:159
A CBot class definition.
Definition: CBotClass.h:105
A CBot variable.
Definition: CBotVar.h:42
CBotClass * GetClass() override
Return class this variable is instance of.
Definition: CBotVarPointer.cpp:167
void Update(void *pUser) override
Call the class update function.
Definition: CBotVarPointer.cpp:64
void SetIdent(long n) override
Associates an unique identifier to class instance.
Definition: CBotVarPointer.cpp:145
CBotVar * GetItem(const std::string &name) override
Returns class member by name.
Definition: CBotVarPointer.cpp:70
long GetIdent()
Returns the unique instance identifier.
Definition: CBotVarPointer.cpp:152
CBotVar subclass for managing pointers to classes (CBotTypPointer)
Definition: CBotVarPointer.h:30
~CBotVarPointer()
Destructor. Do not call directly, use CBotVar::Destroy()
Definition: CBotVarPointer.cpp:58
bool Eq(CBotVar *left, CBotVar *right) override
left == right
Definition: CBotVarPointer.cpp:221
CBotVarPointer(const CBotToken &name, CBotTypResult &type)
Constructor. Do not call directly, use CBotVar::Create()
Definition: CBotVarPointer.cpp:35
Class to define the complete type of a variable.
Definition: CBotTypResult.h:47
std::string GetValString() override
Get value as string.
Definition: CBotVarPointer.cpp:95
CBot engine.
Definition: CBotCallMethode.cpp:28
CBotVar * GetItemList() override
Return all elements of this variable as a linked list. Works for both classes and arrays...
Definition: CBotVarPointer.cpp:88
CBotVar * GetItemRef(int nIdent) override
Returns class member by unique ID.
Definition: CBotVarPointer.cpp:79
CBotVar subclass for managing classes (CBotTypClass, CBotTypIntrinsic)
Definition: CBotVarClass.h:34
bool Save1State(FILE *pf) override
Save variable data.
Definition: CBotVarPointer.cpp:175
Class representing one token of a program.
Definition: CBotToken.h:80