Colobot
|
CBotVar subclass for managing pointers to classes (CBotTypPointer) More...
#include <CBotVarPointer.h>
Public Member Functions | |
CBotVarPointer (const CBotToken &name, CBotTypResult &type) | |
Constructor. Do not call directly, use CBotVar::Create() More... | |
~CBotVarPointer () | |
Destructor. Do not call directly, use CBotVar::Destroy() More... | |
void | Copy (CBotVar *pSrc, bool bName=true) override |
Copy from another variable. More... | |
void | SetClass (CBotClass *pClass) override |
Set class this variable is instance of. More... | |
CBotClass * | GetClass () override |
Return class this variable is instance of. More... | |
CBotVar * | GetItem (const std::string &name) override |
Returns class member by name. More... | |
CBotVar * | GetItemRef (int nIdent) override |
Returns class member by unique ID. More... | |
CBotVar * | GetItemList () override |
Return all elements of this variable as a linked list. Works for both classes and arrays. More... | |
std::string | GetValString () override |
Get value as string. More... | |
void | SetPointer (CBotVar *p) override |
Set value for pointer types. More... | |
CBotVarClass * | GetPointer () override |
Get value for pointer types. More... | |
void | SetIdent (long n) override |
Associates an unique identifier to class instance. More... | |
long | GetIdent () |
Returns the unique instance identifier. More... | |
void | ConstructorSet () override |
Called after constructor has been called. More... | |
bool | Save1State (FILE *pf) override |
Save variable data. More... | |
void | Update (void *pUser) override |
Call the class update function. More... | |
bool | Eq (CBotVar *left, CBotVar *right) override |
left == right More... | |
bool | Ne (CBotVar *left, CBotVar *right) override |
left != right More... | |
![]() | |
CBotVar * | GetStaticVar () |
If this is a static class variable, return the static var from the class. More... | |
void | SetUniqNum (long n) |
Set unique identifier of this variable Note: For classes, this is unique within the class only - see CBotClass:AddItem. More... | |
long | GetUniqNum () |
Return unique identifier of this variable Note: For classes, this is unique within the class only - see CBotClass:AddItem. More... | |
CBotVar () | |
Constructor. Do not call directly, use CBotVar::Create() More... | |
CBotVar (const CBotToken &name) | |
Constructor. Do not call directly, use CBotVar::Create() More... | |
virtual | ~CBotVar () |
Destructor. Do not call directly, use CBotVar::Destroy() More... | |
void | SetUserPtr (void *pUser) |
Set a custom pointer associated with this variable. More... | |
void * | GetUserPtr () |
Returns the custom pointer associated with this variable. More... | |
std::string | GetName () |
Returns the name of the variable. More... | |
void | SetName (const std::string &name) |
SetName Changes the name of the variable. More... | |
CBotToken * | GetToken () |
Returns the CBotToken this variable is associated with. More... | |
CBotType | GetType (GetTypeMode mode=GetTypeMode::NORMAL) |
GetType Returns the base type of the variable (CBotType) More... | |
CBotTypResult | GetTypResult (GetTypeMode mode=GetTypeMode::NORMAL) |
Returns the complete type of the variable (CBotTypResult) More... | |
void | SetType (CBotTypResult &type) |
Change type of this variable. More... | |
void | SetInit (InitType initType) |
Changes variable init status. More... | |
InitType | GetInit () const |
Returns the current init state of the variable. More... | |
bool | IsUndefined () const |
Checks if the variable is currently "undefined". More... | |
bool | IsDefined () const |
Checks if the variable is currently "defined". More... | |
bool | IsNAN () const |
Checks if the variable is currently NAN. More... | |
void | SetStatic (bool bStatic) |
Marks the variable as "static". More... | |
bool | IsStatic () |
Checks if the variable is static. More... | |
void | SetPrivate (ProtectionLevel mPrivate) |
Sets variable protection level. More... | |
bool | IsPrivate (ProtectionLevel level=ProtectionLevel::Protected) |
Checks if the variable is accessible at the given protection level. More... | |
ProtectionLevel | GetPrivate () |
Get variable protection level. More... | |
bool | IsElemOfClass (const std::string &name) |
Check if a variable belongs to a class with a given name. More... | |
virtual CBotVar * | GetItem (int index, bool grow=false) |
Returns element of the array by index. More... | |
operator int () | |
operator float () | |
operator std::string () | |
void | operator= (const CBotVar &var) |
void | operator= (int x) |
void | operator= (float x) |
void | operator= (const std::string &x) |
void | SetVal (CBotVar *var) |
Set the value. More... | |
virtual void | SetValInt (int val, const std::string &name="") |
Set value as an integer. More... | |
virtual void | SetValFloat (float val) |
Set value as float. More... | |
virtual void | SetValString (const std::string &val) |
Set value as string. More... | |
virtual int | GetValInt () |
Get value as integer. More... | |
virtual float | GetValFloat () |
Get value as float. More... | |
virtual void | Add (CBotVar *left, CBotVar *right) |
Addition. More... | |
virtual void | Sub (CBotVar *left, CBotVar *right) |
Subtraction. More... | |
virtual void | Mul (CBotVar *left, CBotVar *right) |
Multiplication. More... | |
virtual CBotError | Div (CBotVar *left, CBotVar *right) |
Division. More... | |
virtual CBotError | Modulo (CBotVar *left, CBotVar *right) |
Modulo (remainder of division) More... | |
virtual void | Power (CBotVar *left, CBotVar *right) |
Power. More... | |
virtual bool | Lo (CBotVar *left, CBotVar *right) |
left < right More... | |
virtual bool | Hi (CBotVar *left, CBotVar *right) |
left > right More... | |
virtual bool | Ls (CBotVar *left, CBotVar *right) |
left <= right More... | |
virtual bool | Hs (CBotVar *left, CBotVar *right) |
left >= right More... | |
virtual void | And (CBotVar *left, CBotVar *right) |
left && right or left & right More... | |
virtual void | Or (CBotVar *left, CBotVar *right) |
left || right or left | right More... | |
virtual void | XOr (CBotVar *left, CBotVar *right) |
left ^ right (also for boolean!) More... | |
virtual void | Not () |
!this or ~this More... | |
virtual void | ASR (CBotVar *left, CBotVar *right) |
left >> right More... | |
virtual void | SR (CBotVar *left, CBotVar *right) |
left >>> right More... | |
virtual void | SL (CBotVar *left, CBotVar *right) |
left << right More... | |
virtual void | Neg () |
-this More... | |
virtual void | Inc () |
++this More... | |
virtual void | Dec () |
–this More... | |
virtual bool | Save0State (FILE *pf) |
Save common variable header (name, type, etc.) More... | |
![]() | |
virtual | ~CBotLinkedList () |
Destructor. Be careful, destroys the whole linked list! More... | |
CBotVar * | GetNext () |
Returns the next variable in the linked list. More... | |
void | AddNext (CBotVar *elem) |
Appends a new element at the end of the linked list. More... | |
Friends | |
class | CBotVar |
Additional Inherited Members | |
![]() | |
enum | GetTypeMode { NORMAL = 0, CLASS_AS_POINTER = 1, CLASS_AS_INTRINSIC = 2 } |
Mode for GetType() and GetTypResult() More... | |
enum | InitType : int { InitType::UNDEF = 0, InitType::DEF = 1, InitType::IS_POINTER = 2, InitType::IS_NAN = 999 } |
Variable initialization status. More... | |
enum | ProtectionLevel { ProtectionLevel::Public = 0, ProtectionLevel::ReadOnly = 1, ProtectionLevel::Protected = 2, ProtectionLevel::Private = 3 } |
Class member protection level (public/protected/private) More... | |
![]() | |
static long | NextUniqNum () |
Generate next unique identifier. More... | |
static CBotVar * | Create (const std::string &name, CBotTypResult type) |
Creates a new variable from a type described by CBotTypResult. More... | |
static CBotVar * | Create (const std::string &name, CBotClass *pClass) |
Creates a new variable of a given class type. More... | |
static CBotVar * | Create (const CBotToken &name, CBotType type) |
Creates a new variable of a given type. More... | |
static CBotVar * | Create (const CBotToken &name, CBotTypResult type) |
Create a new variable of a given type described by CBotTypResult. More... | |
static CBotVar * | Create (const std::string &name, CBotType type, CBotClass *pClass) |
Create a new variable of a given type of given class instance. More... | |
static CBotVar * | Create (CBotVar *pVar) |
Create a new variable of the same type and name as another one. More... | |
static void | Destroy (CBotVar *var) |
Destroy a variable. More... | |
static bool | RestoreState (FILE *pf, CBotVar *&pVar) |
Restore variable. More... | |
![]() | |
CBotToken * | m_token |
The corresponding token, defines the variable name. More... | |
CBotTypResult | m_type |
Type of value. More... | |
InitType | m_binit |
Initialization status. More... | |
CBotVarClass * | m_pMyThis |
Corresponding this element (TODO: ?) More... | |
void * | m_pUserPtr |
User pointer if specified. More... | |
bool | m_bStatic |
true if the variable is static (for classes) More... | |
ProtectionLevel | m_mPrivate |
Element protection level - public, protected or private (for classes) More... | |
CBotInstr * | m_InitExpr |
Expression describing initial value. More... | |
CBotInstr * | m_LimExpr |
Expression describing array limit. More... | |
long | m_ident |
Identifier. More... | |
![]() | |
CBotVar * | m_next |
![]() | |
static long | m_identcpt = 0 |
TODO: ? More... | |
CBotVar subclass for managing pointers to classes (CBotTypPointer)
CBot::CBotVarPointer::CBotVarPointer | ( | const CBotToken & | name, |
CBotTypResult & | type | ||
) |
Constructor. Do not call directly, use CBotVar::Create()
CBot::CBotVarPointer::~CBotVarPointer | ( | ) |
Destructor. Do not call directly, use CBotVar::Destroy()
|
overridevirtual |
Copy from another variable.
pSrc | Variable to copy from |
bName | true if you want to also copy the name |
Reimplemented from CBot::CBotVar.
|
overridevirtual |
Set class this variable is instance of.
Used by instance variables, NOT class members
Reimplemented from CBot::CBotVar.
|
overridevirtual |
Return class this variable is instance of.
Used by instance variables, NOT class members
Reimplemented from CBot::CBotVar.
|
overridevirtual |
Returns class member by name.
name | Name of member to get |
Reimplemented from CBot::CBotVar.
|
overridevirtual |
Returns class member by unique ID.
nIdent | Unique ID of the class member to return |
Reimplemented from CBot::CBotVar.
|
overridevirtual |
Return all elements of this variable as a linked list. Works for both classes and arrays.
Reimplemented from CBot::CBotVar.
|
overridevirtual |
Get value as string.
This one is supported by most types of variables.
Automatically converts the value to string if needed.
Reimplemented from CBot::CBotVar.
|
overridevirtual |
|
overridevirtual |
Get value for pointer types.
Reimplemented from CBot::CBotVar.
|
overridevirtual |
Associates an unique identifier to class instance.
Used only by classes
UniqId | New unique identifier |
Reimplemented from CBot::CBotVar.
long CBot::CBotVarPointer::GetIdent | ( | ) |
Returns the unique instance identifier.
|
overridevirtual |
Called after constructor has been called.
This is used internally by the engine to mark the constructor as called.
This allows the destructor to be called later.
Reimplemented from CBot::CBotVar.
|
overridevirtual |
Save variable data.
Overriden in child classes
pf | file pointer |
Reimplemented from CBot::CBotVar.
|
overridevirtual |
Call the class update function.
pUser | User pointer to pass to the update function |
Reimplemented from CBot::CBotVar.
left == right
Reimplemented from CBot::CBotVar.
left != right
Reimplemented from CBot::CBotVar.