|
Colobot
|
A CBot class definition. More...
#include <src/CBot/CBotClass.h>

Public Member Functions | |
| CBotClass (const std::string &name, CBotClass *parent, bool bIntrinsic=false) | |
| CBotClass Constructor. Once a class is created, it is known around CBot intrinsic mode gives a class that is not managed by pointers. More... | |
| ~CBotClass () | |
| CBotClass Destructor. More... | |
| bool | AddFunction (const std::string &name, bool rExec(CBotVar *pThis, CBotVar *pVar, CBotVar *pResult, int &Exception, void *user), CBotTypResult rCompile(CBotVar *pThis, CBotVar *&pVar)) |
| AddFunction This call allows to add as external new method used by the objects of this class. See (**) at end of this file for more details. More... | |
| bool | SetUpdateFunc (void rUpdate(CBotVar *thisVar, void *user)) |
| SetUpdateFunc Defines routine to be called to update the elements of the class. More... | |
| bool | AddItem (std::string name, CBotTypResult type, CBotVar::ProtectionLevel mPrivate=CBotVar::ProtectionLevel::Public) |
| AddItem Adds an element to the class. More... | |
| bool | AddItem (CBotVar *pVar) |
| AddItem Adds an item by passing the pointer to an instance of a variable the object is taken as is, so do not destroyed. More... | |
| std::string | GetName () |
| GetName Gives the name of the class. More... | |
| CBotClass * | GetParent () |
| GetParent Gives the parent class (or nullptr). More... | |
| bool | IsChildOf (CBotClass *pClass) |
| IsChildOf True if a class is derived (Extends) of another. More... | |
| CBotVar * | GetVar () |
| GetVar Return the list of variables. More... | |
| CBotVar * | GetItem (const std::string &name) |
| GetItem One of the variables according to its name. More... | |
| CBotVar * | GetItemRef (int nIdent) |
| GetItemRef. More... | |
| CBotTypResult | CompileMethode (const std::string &name, CBotVar *pThis, CBotVar **ppParams, CBotCStack *pStack, long &nIdent) |
| CompileMethode Compiles a method associated with an instance of class the method can be declared by the user or AddFunction. More... | |
| bool | ExecuteMethode (long &nIdent, const std::string &name, CBotVar *pThis, CBotVar **ppParams, CBotVar *&pResult, CBotStack *&pStack, CBotToken *pToken) |
| ExecuteMethode Executes a method. More... | |
| void | RestoreMethode (long &nIdent, const std::string &name, CBotVar *pThis, CBotVar **ppParams, CBotStack *&pStack) |
| RestoreMethode Restored the execution stack. More... | |
| bool | CompileDefItem (CBotToken *&p, CBotCStack *pStack, bool bSecond) |
| CompileDefItem. More... | |
| bool | IsIntrinsic () |
| IsIntrinsic. More... | |
| void | Purge () |
| Purge. More... | |
| bool | Lock (CBotProgram *prog) |
| Request a lock on this class (for "synchronized" keyword) More... | |
| void | Unlock () |
| Release the lock acquired in Lock() If you call Lock() multiple times for the same program, you have to call Unlock() multiple times too. More... | |
| bool | CheckCall (CBotProgram *program, CBotDefParam *pParam, CBotToken *&pToken) |
| CheckCall Test if a procedure name is already defined somewhere. More... | |
| void | Update (CBotVar *var, void *user) |
Public Member Functions inherited from CBot::CBotLinkedList< CBotClass > | |
| virtual | ~CBotLinkedList () |
| Destructor. Be careful, destroys the whole linked list! More... | |
| CBotClass * | GetNext () |
| Returns the next variable in the linked list. More... | |
| void | AddNext (CBotClass *elem) |
| Appends a new element at the end of the linked list. More... | |
Static Public Member Functions | |
| static CBotClass * | Create (const std::string &name, CBotClass *parent, bool intrinsic=false) |
| Create. More... | |
| static CBotClass * | Find (CBotToken *&pToken) |
| Find Trouve une classe d'après son nom. More... | |
| static CBotClass * | Find (const std::string &name) |
| Find. More... | |
| static CBotClass * | Compile (CBotToken *&p, CBotCStack *pStack) |
| Compile Compiles a class declared by the user. More... | |
| static CBotClass * | Compile1 (CBotToken *&p, CBotCStack *pStack) |
| Compile1. More... | |
| static void | DefineClasses (CBotClass *pClass, CBotCStack *pStack) |
| DefineClasses Calls CompileDefItem for each class in a list of classes, defining fields and pre-compiling methods. More... | |
| static void | ClearPublic () |
| Free. More... | |
| static bool | SaveStaticState (FILE *pf) |
| SaveStaticState. More... | |
| static bool | RestoreStaticState (FILE *pf) |
| RestoreStaticState. More... | |
| static void | FreeLock (CBotProgram *prog) |
| Release all locks in all classes held by this program. More... | |
Additional Inherited Members | |
Protected Attributes inherited from CBot::CBotLinkedList< CBotClass > | |
| CBotClass * | m_next |
A CBot class definition.
Define class "point":
Define readonly class "object" with members of type "point" and some methods:
Define class "robot" derrived from "object":
Create instance of the "robot" class:
Access members of the "point" class:
| CBot::CBotClass::CBotClass | ( | const std::string & | name, |
| CBotClass * | parent, | ||
| bool | bIntrinsic = false |
||
| ) |
| CBot::CBotClass::~CBotClass | ( | ) |
CBotClass Destructor.
|
static |
Create.
| name | |
| parent | |
| intrinsic |
| bool CBot::CBotClass::AddFunction | ( | const std::string & | name, |
| bool | rExecCBotVar *pThis, CBotVar *pVar, CBotVar *pResult, int &Exception, void *user, | ||
| CBotTypResult | rCompileCBotVar *pThis, CBotVar *&pVar | ||
| ) |
AddFunction This call allows to add as external new method used by the objects of this class. See (**) at end of this file for more details.
| name | |
| rExec | |
| rCompile |
| bool CBot::CBotClass::SetUpdateFunc | ( | void | rUpdateCBotVar *thisVar, void *user | ) |
SetUpdateFunc Defines routine to be called to update the elements of the class.
| rUpdate |
| bool CBot::CBotClass::AddItem | ( | std::string | name, |
| CBotTypResult | type, | ||
| CBotVar::ProtectionLevel | mPrivate = CBotVar::ProtectionLevel::Public |
||
| ) |
AddItem Adds an element to the class.
| name | |
| type | |
| mPrivate |
pVar->SetUniqNum(CBotVar::NextUniqNum());
| bool CBot::CBotClass::AddItem | ( | CBotVar * | pVar | ) |
AddItem Adds an item by passing the pointer to an instance of a variable the object is taken as is, so do not destroyed.
| pVar |
| std::string CBot::CBotClass::GetName | ( | ) |
GetName Gives the name of the class.
| CBotClass * CBot::CBotClass::GetParent | ( | ) |
GetParent Gives the parent class (or nullptr).
| bool CBot::CBotClass::IsChildOf | ( | CBotClass * | pClass | ) |
IsChildOf True if a class is derived (Extends) of another.
| pClass |
Find Trouve une classe d'après son nom.
| pToken |
|
static |
Find.
| name |
| CBotVar * CBot::CBotClass::GetVar | ( | ) |
GetVar Return the list of variables.
| CBotVar * CBot::CBotClass::GetItem | ( | const std::string & | name | ) |
GetItem One of the variables according to its name.
| name |
| CBotVar * CBot::CBotClass::GetItemRef | ( | int | nIdent | ) |
GetItemRef.
| nIdent |
| CBotTypResult CBot::CBotClass::CompileMethode | ( | const std::string & | name, |
| CBotVar * | pThis, | ||
| CBotVar ** | ppParams, | ||
| CBotCStack * | pStack, | ||
| long & | nIdent | ||
| ) |
CompileMethode Compiles a method associated with an instance of class the method can be declared by the user or AddFunction.
| name | |
| pThis | |
| ppParams | |
| pStack | |
| nIdent |
| bool CBot::CBotClass::ExecuteMethode | ( | long & | nIdent, |
| const std::string & | name, | ||
| CBotVar * | pThis, | ||
| CBotVar ** | ppParams, | ||
| CBotVar *& | pResult, | ||
| CBotStack *& | pStack, | ||
| CBotToken * | pToken | ||
| ) |
ExecuteMethode Executes a method.
| nIdent | |
| name | |
| pThis | |
| ppParams | |
| pResult | |
| pStack | |
| pToken |
| void CBot::CBotClass::RestoreMethode | ( | long & | nIdent, |
| const std::string & | name, | ||
| CBotVar * | pThis, | ||
| CBotVar ** | ppParams, | ||
| CBotStack *& | pStack | ||
| ) |
RestoreMethode Restored the execution stack.
| nIdent | |
| name | |
| pThis | |
| ppParams | |
| pStack |
|
static |
Compile Compiles a class declared by the user.
| p | |
| pStack |
|
static |
Compile1.
| p | |
| pStack |
|
static |
DefineClasses Calls CompileDefItem for each class in a list of classes, defining fields and pre-compiling methods.
| pClass | List of classes |
| pStack |
| bool CBot::CBotClass::CompileDefItem | ( | CBotToken *& | p, |
| CBotCStack * | pStack, | ||
| bool | bSecond | ||
| ) |
CompileDefItem.
| p | |
| pStack | |
| bSecond |
| bool CBot::CBotClass::IsIntrinsic | ( | ) |
IsIntrinsic.
| void CBot::CBotClass::Purge | ( | ) |
Purge.
|
static |
Free.
|
static |
SaveStaticState.
| pf |
|
static |
RestoreStaticState.
| pf |
| bool CBot::CBotClass::Lock | ( | CBotProgram * | prog | ) |
Request a lock on this class (for "synchronized" keyword)
| prog | Program that requests the lock |
| void CBot::CBotClass::Unlock | ( | ) |
|
static |
Release all locks in all classes held by this program.
| prog | Program to release the locks from |
| bool CBot::CBotClass::CheckCall | ( | CBotProgram * | program, |
| CBotDefParam * | pParam, | ||
| CBotToken *& | pToken | ||
| ) |
CheckCall Test if a procedure name is already defined somewhere.
| program | |
| pToken | |
| pParam |
1.8.12