From 33ac24629796fd722433040fcba04155b8342ca2 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Tue, 22 Dec 2015 15:59:57 +0100 Subject: [PATCH] Documentation for CBotVar and all subclasses --- Doxyfile.in | 2 +- src/CBot/CBotProgram.h | 4 +- src/CBot/CBotTypResult.h | 1 - src/CBot/CBotVar/CBotVar.cpp | 27 +- src/CBot/CBotVar/CBotVar.h | 1006 ++++++++++++++------------- src/CBot/CBotVar/CBotVarArray.h | 71 +- src/CBot/CBotVar/CBotVarBoolean.cpp | 5 +- src/CBot/CBotVar/CBotVarBoolean.h | 91 +-- src/CBot/CBotVar/CBotVarClass.cpp | 7 - src/CBot/CBotVar/CBotVarClass.h | 151 +--- src/CBot/CBotVar/CBotVarFloat.h | 145 +--- src/CBot/CBotVar/CBotVarInt.h | 201 +----- src/CBot/CBotVar/CBotVarPointer.h | 112 +-- src/CBot/CBotVar/CBotVarString.cpp | 4 +- src/CBot/CBotVar/CBotVarString.h | 87 +-- 15 files changed, 639 insertions(+), 1275 deletions(-) diff --git a/Doxyfile.in b/Doxyfile.in index 0b6a1a5b..c55e3284 100644 --- a/Doxyfile.in +++ b/Doxyfile.in @@ -554,7 +554,7 @@ INLINE_INFO = YES # name. If set to NO, the members will appear in declaration order. # The default value is: YES. -SORT_MEMBER_DOCS = YES +SORT_MEMBER_DOCS = NO # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief # descriptions of file, namespace and class members alphabetically by member diff --git a/src/CBot/CBotProgram.h b/src/CBot/CBotProgram.h index 11d44024..41b71680 100644 --- a/src/CBot/CBotProgram.h +++ b/src/CBot/CBotProgram.h @@ -122,12 +122,12 @@ public: bool Compile(const std::string& program, std::vector& functions, void* pUser = nullptr); /** - * \brief Associates an identifier with this instance of CBotProgram + * \brief Associates an unique identifier with this instance of CBotProgram */ void SetIdent(long n); /** - * \brief Returns the identifier + * \brief Returns the unique identifier * \see SetIdent */ long GetIdent(); diff --git a/src/CBot/CBotTypResult.h b/src/CBot/CBotTypResult.h index 085422f7..98aeeeb5 100644 --- a/src/CBot/CBotTypResult.h +++ b/src/CBot/CBotTypResult.h @@ -126,7 +126,6 @@ public: /** * \brief Get type of array elements (for ::CBotTypArrayBody or ::CBotTypArrayPointer) - * \param n new value */ CBotTypResult& GetTypElem() const; diff --git a/src/CBot/CBotVar/CBotVar.cpp b/src/CBot/CBotVar/CBotVar.cpp index cc86620d..7b15ef39 100644 --- a/src/CBot/CBotVar/CBotVar.cpp +++ b/src/CBot/CBotVar/CBotVar.cpp @@ -32,6 +32,7 @@ #include "CBot/CBotVar/CBotVarInt.h" #include "CBot/CBotClass.h" +#include "CBot/CBotToken.h" #include "CBot/CBotEnums.h" @@ -136,7 +137,7 @@ void CBotVar::Maj(void* pUser, bool bContinu) } //////////////////////////////////////////////////////////////////////////////// -CBotVar* CBotVar::Create(const CBotToken* name, int type ) +CBotVar* CBotVar::Create(const CBotToken* name, CBotType type ) { CBotTypResult t(type); return Create(name, t); @@ -269,7 +270,7 @@ CBotVar* CBotVar::Create(const std::string& n, CBotTypResult type) } //////////////////////////////////////////////////////////////////////////////// -CBotVar* CBotVar::Create(const std::string& name, int type, CBotClass* pClass) +CBotVar* CBotVar::Create(const std::string& name, CBotType type, CBotClass* pClass) { CBotToken token( name, "" ); CBotVar* pVar = Create( &token, type ); @@ -319,13 +320,13 @@ CBotTypResult CBotVar::GetTypResult(int mode) } //////////////////////////////////////////////////////////////////////////////// -int CBotVar::GetType(int mode) +CBotType CBotVar::GetType(int mode) { if ( mode == 1 && m_type.Eq(CBotTypClass) ) return CBotTypPointer; if ( mode == 2 && m_type.Eq(CBotTypClass) ) return CBotTypIntrinsic; - return m_type.GetType(); + return static_cast(m_type.GetType()); } //////////////////////////////////////////////////////////////////////////////// @@ -343,12 +344,12 @@ CBotVar::InitType CBotVar::GetInit() const } //////////////////////////////////////////////////////////////////////////////// -void CBotVar::SetInit(CBotVar::InitType bInit) +void CBotVar::SetInit(CBotVar::InitType initType) { - m_binit = bInit; - if ( bInit == CBotVar::InitType::IS_POINTER ) m_binit = CBotVar::InitType::DEF; // cas spécial + m_binit = initType; + if (initType == CBotVar::InitType::IS_POINTER ) m_binit = CBotVar::InitType::DEF; // cas spécial - if ( m_type.Eq(CBotTypPointer) && bInit == CBotVar::InitType::IS_POINTER ) + if ( m_type.Eq(CBotTypPointer) && initType == CBotVar::InitType::IS_POINTER ) { CBotVarClass* instance = GetPointer(); if ( instance == nullptr ) @@ -365,7 +366,7 @@ void CBotVar::SetInit(CBotVar::InitType bInit) CBotVar* p = (static_cast(this))->m_pVar; while( p != nullptr ) { - p->SetInit( bInit ); + p->SetInit(initType); p->m_pMyThis = static_cast(this); p = p->GetNext(); } @@ -412,7 +413,7 @@ CBotVar* CBotVar::GetItemList() } //////////////////////////////////////////////////////////////////////////////// -CBotVar* CBotVar::GetItem(int row, bool bGrow) +CBotVar* CBotVar::GetItem(int index, bool grow) { assert(0); return nullptr; @@ -521,9 +522,9 @@ bool CBotVar::IsStatic() } //////////////////////////////////////////////////////////////////////////////// -bool CBotVar::IsPrivate(ProtectionLevel mode) +bool CBotVar::IsPrivate(ProtectionLevel level) { - return static_cast(m_mPrivate) >= static_cast(mode); + return static_cast(m_mPrivate) >= static_cast(level); } //////////////////////////////////////////////////////////////////////////////// @@ -720,7 +721,7 @@ void CBotVar::Copy(CBotVar* pSrc, bool bName) } //////////////////////////////////////////////////////////////////////////////// -void CBotVar::SetValString(const std::string& p) +void CBotVar::SetValString(const std::string& val) { assert(0); } diff --git a/src/CBot/CBotVar/CBotVar.h b/src/CBot/CBotVar/CBotVar.h index 39e3b6c9..fe92e442 100644 --- a/src/CBot/CBotVar/CBotVar.h +++ b/src/CBot/CBotVar/CBotVar.h @@ -19,594 +19,657 @@ #pragma once -// Modules inlcude #include "CBot/CBotDefines.h" #include "CBot/CBotTypResult.h" +#include "CBot/CBotEnums.h" -// Local include - -// Global include #include -#include -// Forward declaration class CBotVarClass; class CBotInstr; class CBotClass; class CBotToken; -/*! - * \brief The CBotVar class Class for managing variables. May be useful to the - * outside of the module ( it is currently not expected to be able to create - * these objects in outer ). It never creates an instance of the class mother - * CBotVar. +/** + * \brief A CBot variable + * + * \nosubgrouping */ class CBotVar { public: - /*! - * \brief The InitType enum Results of GetInit(). - */ - enum class InitType : int - { - UNDEF = 0, - DEF = 1, - IS_POINTER = 2, - IS_NAN = 999 - }; + //! \name Creation / destruction + //@{ - /*! - * \brief CBotVar + /** + * \brief Constructor. Do not call directly, use CBotVar::Create() */ CBotVar(); - /*! - * \brief ~CBotVar Destructor. + /** + * \brief Destructor. Do not call directly, use CBotVar::Destroy() */ - virtual ~CBotVar( ); + virtual ~CBotVar(); - /*! - * \brief Create Creates from a complete type. - * \param name - * \param type - * \return + /** + * \brief Creates a new variable from a type described by CBotTypResult + * \param name Variable name + * \param type Variable type */ static CBotVar* Create(const std::string& name, CBotTypResult type); - /*! - * \brief Create Creates from one instance of a known class. - * \param name - * \param pClass - * \return + /** + * \brief Creates a new variable of a given class type + * + * This is equivalent to: + * \code + * CBotVar::Create(name, CBotTypResult(CBotTypClass, pClass)) + * \endcode + * + * \param name Variable name + * \param pClass Class type */ static CBotVar* Create(const std::string& name, CBotClass* pClass); - /*! - * \brief Create Creates a variable depending on its type. - * \param name - * \param type + /** + * \brief Creates a new variable of a given type + * + * This is equivalent to: + * \code + * CBotVar::Create(name, CBotTypResult(type)) + * \endcode + * + * \param name Variable name token + * \param type Variable type + */ + static CBotVar* Create(const CBotToken* name, CBotType type); + + /** + * \brief Create a new variable of a given type described by CBotTypResult + * \param name Variable name token + * \param type Variable type + */ + static CBotVar* Create(const CBotToken* name, CBotTypResult type); + + /** + * \brief Create a new variable of a given type of given class instance + * + * This is equivalent to: + * \code + * Create(name, CBotTypResult(type, pClass)) + * \endcode + * + * \param name Variable name + * \param type Variable type + * \param pClass Class * \return */ - static CBotVar* Create( const CBotToken* name, int type ); + static CBotVar* Create(const std::string& name, CBotType type, CBotClass* pClass); - /*! - * \brief Create - * \param name - * \param type - * \return + /** + * \brief Create a new variable of the same type and name as another one + * + * Contents of the variable are NOT copied. + * + * \param pVar other variable to take type and name from */ - static CBotVar* Create( const CBotToken* name, CBotTypResult type ); + static CBotVar* Create(CBotVar* pVar); - /*! - * \brief Create - * \param name - * \param type - * \param pClass - * \return - */ - static CBotVar* Create(const std::string& name, int type, CBotClass* pClass); - - /*! - * \brief Create - * \param pVar - * \return - */ - static CBotVar* Create( CBotVar* pVar ); - - /*! - * \brief Destroy - * \param var + /** + * \brief Destroy a variable + * \param var variable to be destroyed */ static void Destroy(CBotVar* var); - /*! - * \brief SetUserPtr Associate a user pointer to an instance. - * \param pUser - */ - void SetUserPtr(void* pUser); + //@} - /*! - * \brief SetIdent Associates a unique identifier to an instance - * ( it is used to ensure that the id is unique) - * \param UniqId + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * \brief Associates an unique identifier to class instance + * + * Used only by classes + * + * \param UniqId New unique identifier + * \see SetUniqNum() for another identifier, used for all variable types */ virtual void SetIdent(long UniqId); - /*! - * \brief GetUserPtr Makes the pointer associated with the variable. - * \return + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //! \name User pointer + //@{ + + /** + * \brief Set a custom pointer associated with this variable + * \param pUser custom pointer to set + */ + void SetUserPtr(void* pUser); + + /** + * \brief Returns the custom pointer associated with this variable + * \return A pointer set with SetUserPtr() */ void* GetUserPtr(); - /*! - * \brief GetName The name of the variable, if known. - * \return + //@} + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //! \name Variable name and type + //@{ + + /** + * \brief Returns the name of the variable + * \return The name of the variable, empty string if unknown */ std::string GetName(); - /*! + /** * \brief SetName Changes the name of the variable - * \param name + * \param name New name */ void SetName(const std::string& name); - /*! - * \brief GetType Returns the base type (int) of the variable - * \param mode - * \return - * \todo Check it? - */ - int GetType(int mode = 0); - - /*! - * \brief GetTypResult Returns the complete type of the variable. - * \param mode - * \return - */ - CBotTypResult GetTypResult(int mode = 0); - - /*! - * \brief GetToken - * \return + /** + * \brief Returns the CBotToken this variable is associated with + * + * This token is either passed in CBotVar::Create() or created from name string */ CBotToken* GetToken(); - /*! - * \brief SetType - * \param type + /** + * \brief GetType Returns the base type of the variable (::CBotType) + * \param mode TODO: document this param + */ + CBotType GetType(int mode = 0); + + /** + * \brief Returns the complete type of the variable (CBotTypResult) + * \param mode TODO: document this param + */ + CBotTypResult GetTypResult(int mode = 0); + + /** + * \brief Change type of this variable + * \param type new type */ void SetType(CBotTypResult& type); - /*! - * \brief SetInit Is the variable in the state UNDEF, DEF, NAN. - * \param initType + /** + * \brief Set class this variable is instance of + * + * Used by instance variables, NOT class members + */ + virtual void SetClass(CBotClass* pClass); + + /** + * \brief Return class this variable is instance of + * + * Used by instance variables, NOT class members + */ + virtual CBotClass* GetClass(); + + //@} + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //! \name Initialization status + //@{ + + /** + * \brief Variable initialization status + * + * \see GetInit() + */ + enum class InitType : int + { + UNDEF = 0, //!< the variable value is currently not defined + DEF = 1, //!< the variable value is defined + IS_POINTER = 2, //!< the variable value is as a pointer + IS_NAN = 999 //!< the variable value is NAN + }; + + /** + * \brief Changes variable init status + * \param initType New init status */ void SetInit(InitType initType); - /*! - * \brief GetInit Gives the state of the variable. - * \return + /** + * \brief Returns the current init state of the variable */ InitType GetInit() const; - /*! - * \brief IsUndefined - * \return + /** + * \brief Checks if the variable is currently "undefined" + * \see InitType::UNDEF */ bool IsUndefined() const { return GetInit() == InitType::UNDEF; } - /*! - * \brief IsDefined - * \return + /** + * \brief Checks if the variable is currently "defined" + * \see InitType::DEF */ bool IsDefined() const { return GetInit() == InitType::DEF; } - /*! - * \brief IsNAN - * \return + /** + * \brief Checks if the variable is currently NAN + * \return InitType::NAN */ bool IsNAN() const { return GetInit() == InitType::IS_NAN; } - /*! - * \brief SetStatic - * \param bStatic + //@} + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //! \name Class member properties + //@{ + + /** + * \brief Marks the variable as "static" + * + * Useful only for class members + * + * \param bStatic static or not */ void SetStatic(bool bStatic); - /*! - * \brief IsStatic - * \return + /** + * \brief Checks if the variable is static + * + * Useful only for class members + * + * \return true for static variables */ bool IsStatic(); + /** + * \enum ProtectionLevel + * \brief Class member protection level (public/protected/private) + */ enum class ProtectionLevel { Public = 0, //!< public variable ReadOnly = 1, //!< read only (can't be set from CBot, only from the engine) - Protected = 2, //!< protected (inheritance) + Protected = 2, //!< protected Private = 3 //!< private }; - /*! - * \brief SetPrivate - * \param mPrivate + /** + * \brief Sets variable protection level + * + * Useful only for class members + * + * \param mPrivate New protection level */ void SetPrivate(ProtectionLevel mPrivate); - /*! - * \brief IsPrivate - * \param mode - * \return + /** + * \brief Checks if the variable is accessible at the given protection level + * + * This means that the variable protection level is greater or equal to given level + * + * \param level Protection level to check access at */ - bool IsPrivate(ProtectionLevel mode = ProtectionLevel::Protected); + bool IsPrivate(ProtectionLevel level = ProtectionLevel::Protected); - /*! - * \brief GetPrivate - * \return + /** + * \brief Get variable protection level + * \return Variable protection level */ ProtectionLevel GetPrivate(); - /*! - * \brief ConstructorSet + /** + * \brief Check if a variable belongs to a class with a given name + * + * Works correctly with inheritance. + * + * \param name Class name to check + * \return true if this variable name matches any member of given class or any of the parent classes + */ + bool IsElemOfClass(const std::string& name); + + //@} + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * \brief 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. */ virtual void ConstructorSet(); - /*! - * \brief SetVal Set the value. - * \param var - */ - void SetVal(CBotVar* var); - - /*! - * \brief GetItem Returns an element of a class according to its name (*). - * \param name - * \return - */ - virtual CBotVar* GetItem(const std::string& name); - - /*! - * \brief GetItemRef - * \param nIdent - * \return - */ - virtual CBotVar* GetItemRef(int nIdent); - - /*! - * \brief GetItem - * \param row - * \param bGrow - * \return - */ - virtual CBotVar* GetItem(int row, bool bGrow = false); - - /*! - * \brief GetItemList Lists the elements. - * \return - */ - virtual CBotVar* GetItemList(); - - /*! - * \brief GetStaticVar Makes the pointer to the variable if it is static. + /** + * \brief TODO: document, original description: Makes the pointer to the variable if it is static. * \return */ CBotVar* GetStaticVar(); - /*! - * \brief IsElemOfClass Check if a variable belongs to a given class said if - * the element belongs to the class "name" makes true if the object is a - * subclass. - * \param name - * \return - */ - bool IsElemOfClass(const std::string& name); - - /*! - * \brief GetNext Next variable in the list (parameters). - * \return - */ - CBotVar* GetNext(); - - /*! - * \brief AddNext Added to a list. - * \param pVar - */ - void AddNext(CBotVar* pVar); - - /*! - * \brief Copy Makes a copy of the variable. - * \param pSrc - * \param bName - */ - virtual void Copy(CBotVar* pSrc, bool bName = true); - - /*! - * \brief SetValInt Initialized with an integer value (#) - * \param val - * \param name - */ - virtual void SetValInt(int val, const std::string& name = ""); - - /*! - * \brief SetValFloat Initialized with a real value (#). - * \param val - */ - virtual void SetValFloat(float val); - - /*! - * \brief SetValString Initialized with a string value (#). - * \param p - */ - virtual void SetValString(const std::string& p); - - /*! - * \brief GetValInt Request the full value (#). - * \return - */ - virtual int GetValInt(); - - /*! - * \brief GetValFloat Gets real value (#). - * \return - */ - virtual float GetValFloat(); - - /*! - * \brief GetValString Request the string value (#). - * \return - */ - virtual std::string GetValString(); - - /*! - * \brief SetClass - * \param pClass - */ - virtual void SetClass(CBotClass* pClass); - - /*! - * \brief GetClass - * \return - */ - virtual CBotClass* GetClass(); - - /*! - * \brief SetPointer - * \param p - */ - virtual void SetPointer(CBotVar* p); - - /*! - * \brief GetPointer - * \return - */ - virtual CBotVarClass* GetPointer(); - - /*! - * \brief Add Addition - * \param left - * \param right - */ - virtual void Add(CBotVar* left, CBotVar* right); - - /*! - * \brief Sub Subtraction - * \param left - * \param right - */ - virtual void Sub(CBotVar* left, CBotVar* right); - - /*! - * \brief Mul Multiplication - * \param left - * \param right - */ - virtual void Mul(CBotVar* left, CBotVar* right); - - /*! - * \brief Div Division - * \param left - * \param right - * \return - */ - virtual CBotError Div(CBotVar* left, CBotVar* right); - - /*! - * \brief Modulo Remainder of division - * \param left - * \param right - * \return - */ - virtual CBotError Modulo(CBotVar* left, CBotVar* right); - - /*! - * \brief Power - * \param left - * \param right - */ - virtual void Power(CBotVar* left, CBotVar* right); - - /*! - * \brief Lo - * \param left - * \param right - * \return - */ - virtual bool Lo(CBotVar* left, CBotVar* right); - - /*! - * \brief Hi - * \param left - * \param right - * \return - */ - virtual bool Hi(CBotVar* left, CBotVar* right); - - /*! - * \brief Ls - * \param left - * \param right - * \return - */ - virtual bool Ls(CBotVar* left, CBotVar* right); - - /*! - * \brief Hs - * \param left - * \param right - * \return - */ - virtual bool Hs(CBotVar* left, CBotVar* right); - - /*! - * \brief Eq - * \param left - * \param right - * \return - */ - virtual bool Eq(CBotVar* left, CBotVar* right); - - /*! - * \brief Ne - * \param left - * \param right - * \return - */ - virtual bool Ne(CBotVar* left, CBotVar* right); - - /*! - * \brief And - * \param left - * \param right - */ - virtual void And(CBotVar* left, CBotVar* right); - - /*! - * \brief Or - * \param left - * \param right - */ - virtual void Or(CBotVar* left, CBotVar* right); - - /*! - * \brief XOr - * \param left - * \param right - */ - virtual void XOr(CBotVar* left, CBotVar* right); - - /*! - * \brief ASR - * \param left - * \param right - */ - virtual void ASR(CBotVar* left, CBotVar* right); - - /*! - * \brief SR - * \param left - * \param right - */ - virtual void SR(CBotVar* left, CBotVar* right); - - /*! - * \brief SL - * \param left - * \param right - */ - virtual void SL(CBotVar* left, CBotVar* right); - - /*! - * \brief Neg - */ - virtual void Neg(); - - /*! - * \brief Not - */ - virtual void Not(); - - /*! - * \brief Inc - */ - virtual void Inc(); - - /*! - * \brief Dec - */ - virtual void Dec(); - - /*! - * \brief Save0State - * \param pf - * \return - */ - virtual bool Save0State(FILE* pf); - - /*! - * \brief Save1State - * \param pf - * \return - */ - virtual bool Save1State(FILE* pf); - - /*! - * \brief RestoreState - * \param pf - * \param pVar - * \return - */ - static bool RestoreState(FILE* pf, CBotVar* &pVar); - - /*! - * \brief Maj - * \param pUser - * \param bContinue + /** + * \brief Call the class update function + * + * \param pUser user pointer to pass to the update function + * \param bContinue UNUSED + * \see CBotClass::SetUpdateFunc() */ virtual void Maj(void* pUser = nullptr, bool bContinue = true); - /*! - * \brief SetUniqNum - * \param n + /** + * \brief Set unique identifier of this variable + * \param n New identifier */ void SetUniqNum(long n); - /*! - * \brief GetUniqNum - * \return + /** + * \brief Return unique identifier of this variable + * \return Identifier + * \see SetUniqNum() */ long GetUniqNum(); - /*! - * \brief NextUniqNum - * \return + /** + * \brief TODO: ? */ static long NextUniqNum(); + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //! \name Class / array member access + //@{ + + /** + * \brief Returns class member by name + * \param name Name of member to get + * \return CBotVar representing the class member + */ + virtual CBotVar* GetItem(const std::string& name); + + /** + * \brief Returns class member by unique ID + * \param nIdent Unique ID of the class member to return + * \return CBotVar representing the class member + * \see GetUniqNum() + */ + virtual CBotVar* GetItemRef(int nIdent); + + /** + * \brief Returns element of the array by index + * + * TODO: Appears to be also implemented in CBotVarClass, but I'm not sure what is it used for there. Looks like CBotVarArray stores data internally in CBotVarClass or something like that. Needs futher investigation. + * + * \param index Index of the element to get + * \param grow true to grow the array automatically if the index is out of range + * \return CBotVar representing the array element + */ + virtual CBotVar* GetItem(int index, bool grow = false); + + /** + * \brief Return all elements of this variable as a linked list. Works for both classes and arrays. + * \return CBotVar representing the first object in the linked list. Use CBotVar::GetNext() to access next ones. + */ + virtual CBotVar* GetItemList(); + + //@} + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //! \name Linked list + //@{ + + /** + * \brief Returns the next variable if this CBotVar is used as a linked list + * \return Next element in the list, or nullptr if this was the last element + */ + CBotVar* GetNext(); + + /** + * \brief Appends a new element at the end of the linked list + * \param pVar Element to add + */ + void AddNext(CBotVar* pVar); + + //@} + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /** + * \name Value management + * + * Always make sure that the variable has correct type before calling these functions! + * + * Some variable types have multiple getters/setters and do automatic conversion. + * + * Using one that is not implemented will result in a failed assertion. + */ + //@{ + + /** + * \brief Set the value + * \param var Another variable to copy value from + */ + void SetVal(CBotVar* var); + + /** + * \brief Copy from another variable + * \param pSrc Variable to copy from + * \param bName true if you want to also copy the name + */ + virtual void Copy(CBotVar* pSrc, bool bName = true); + + /** + * \brief Set value as an integer + * + * This one should be used for boolean values, too + * + * \param val New value + * \param name Used when you assign a constant value - makes the value appear as "name" instead of number in the debugger + */ + virtual void SetValInt(int val, const std::string& name = ""); + + /** + * \brief Set value as float + * \param val New value + */ + virtual void SetValFloat(float val); + + /** + * \brief Set value as string + * \param val New value + */ + virtual void SetValString(const std::string& val); + + /** + * \brief Get value as integer + * \return Current value + */ + virtual int GetValInt(); + + /** + * \brief Get value as float + * \return Current value + */ + virtual float GetValFloat(); + + /** + * \brief Get value as string + * + * This one is supported by most types of variables. + * + * Automatically converts the value to string if needed. + * + * \return Current value + */ + virtual std::string GetValString(); + + /** + * \brief Set value for pointer types + * \param p Variable to point to + */ + virtual void SetPointer(CBotVar* p); + + /** + * \brief Get value for pointer types + * \return Variable that this variable points to + */ + virtual CBotVarClass* GetPointer(); + + //@} + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /** + * \name Math operations + * + * All these functions operate on the "left" variable, taking "right" as the argument. + * + * The C++ equivalent would be the +=, -=, *=, /= etc. operations + */ + //@{ + + //! \brief Addition + virtual void Add(CBotVar* left, CBotVar* right); + //! \brief Subtraction + virtual void Sub(CBotVar* left, CBotVar* right); + //! \brief Multiplication + virtual void Mul(CBotVar* left, CBotVar* right); + //! \brief Division + virtual CBotError Div(CBotVar* left, CBotVar* right); + //! \brief Modulo (remainder of division) + virtual CBotError Modulo(CBotVar* left, CBotVar* right); + //! \brief Power + virtual void Power(CBotVar* left, CBotVar* right); + + //@} + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //! \name Comparation functions + //@{ + + //! \brief left < right + virtual bool Lo(CBotVar* left, CBotVar* right); + //! \brief left > right + virtual bool Hi(CBotVar* left, CBotVar* right); + //! \brief left <= right + virtual bool Ls(CBotVar* left, CBotVar* right); + //! \brief left >= right + virtual bool Hs(CBotVar* left, CBotVar* right); + //! \brief left == right + virtual bool Eq(CBotVar* left, CBotVar* right); + //! \brief left != right + virtual bool Ne(CBotVar* left, CBotVar* right); + + //@} + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /** + * \name Logical or bitwise functions + * + * Can be either depending on variable type. + * + * For boolean, those are logical functions, for int they are bitwise. + */ + + //! \brief left && right or left & right + virtual void And(CBotVar* left, CBotVar* right); + //! \brief left || right or left | right + virtual void Or(CBotVar* left, CBotVar* right); + //! \brief left ^ right (also for boolean!) + virtual void XOr(CBotVar* left, CBotVar* right); + //!\brief !this or ~this + virtual void Not(); + + //@} + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //! \name Bitwise shift + //@{ + + //! \brief left >> right + virtual void ASR(CBotVar* left, CBotVar* right); + //! \brief left >>> right + /** + * This is unsigned shift to right + */ + virtual void SR(CBotVar* left, CBotVar* right); + //! \brief left << right + virtual void SL(CBotVar* left, CBotVar* right); + + //@} + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //! \name Negation / increment / decrement + //@{ + + //! \brief -this + virtual void Neg(); + //! \brief ++this + virtual void Inc(); + //! \brief --this + virtual void Dec(); + + //@} + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //! \name Save / restore state + //@{ + + /** + * \brief Save common variable header (name, type, etc.) + * \param pf file pointer + * \return false on write error + */ + virtual bool Save0State(FILE* pf); + + /** + * \brief Save variable data + * + * Overriden in child classes + * + * \param pf file pointer + * \return false on write error + */ + virtual bool Save1State(FILE* pf); + + /** + * \brief Restore variable + * \param pf file pointer + * \param[out] pVar Pointer to recieve the variable + * \return false on read error + */ + static bool RestoreState(FILE* pf, CBotVar* &pVar); + + //@} + protected: - //! The corresponding token. + //! The corresponding token, defines the variable name CBotToken* m_token; - //! List of variables. - CBotVar* m_next; //! Type of value. CBotTypResult m_type; - //! Not initialized. + //! Next variable in a linked list + CBotVar* m_next; + //! Initialization status InitType m_binit; - //! Corresponding this element. + //! Corresponding this element (TODO: ?) CBotVarClass* m_pMyThis; - //! User data if necessary. + //! User pointer if specified + /** + * \see SetUserPtr() + * \see GetUserPtr() + */ void* m_pUserPtr; - //! Static element (in class). + //! true if the variable is static (for classes) bool m_bStatic; - //! Element public, protected or private. + //! Element protection level - public, protected or private (for classes) ProtectionLevel m_mPrivate; - //! Expression for the original content. + //! Expression describing initial value CBotInstr* m_InitExpr; - //! List of limits for a table. + //! Expression describing array limit CBotInstr* m_LimExpr; - //! Unique identifier. + //! Identifier + /** + * \see SetUniqNum() + * \see GetUniqNum() + */ long m_ident; - //! Counter + //! TODO: ? static long m_identcpt; friend class CBotStack; @@ -618,16 +681,3 @@ protected: friend class CBotVarPointer; friend class CBotVarArray; }; - -/* NOTE (#) - methods SetValInt() SetValFloat() et SetValString() - can be called with objects which are respectively integer, real or string - Always be sure of the type of the variable before calling these methods - - if ( pVar->GetType() == CBotInt() ) pVar->SetValFloat( 3.3 ); // plante !! - - methods GetValInt(), GetValFloat() et GetValString() - use value conversions, - GetValString() works on numbers (makes the corresponding string) - but do not make GetValInt () with a string variable! -*/ diff --git a/src/CBot/CBotVar/CBotVarArray.h b/src/CBot/CBotVar/CBotVarArray.h index 5ce4b5b2..989c4fd0 100644 --- a/src/CBot/CBotVar/CBotVarArray.h +++ b/src/CBot/CBotVar/CBotVarArray.h @@ -19,85 +19,38 @@ #pragma once -// Modules inlcude -#include "CBot/CBotDefines.h" - #include "CBot/CBotVar/CBotVar.h" -// Local include - -// Global include - - -/*! - * \brief The CBotVarArray class Classe pour les tableaux. +/** + * \brief CBotVar subclass for managing arrays (::CBotTypArrayPointer) + * + * Uses CBotVarClass for storing data internally */ class CBotVarArray : public CBotVar { public: - - /*! - * \brief CBotVarArray - * \param name - * \param type + /** + * \brief Constructor. Do not call directly, use CBotVar::Create() */ - CBotVarArray( const CBotToken* name, CBotTypResult& type ); - - /*! - * \brief ~CBotVarArray + CBotVarArray(const CBotToken* name, CBotTypResult& type); + /** + * \brief Destructor. Do not call directly, use CBotVar::Destroy() */ ~CBotVarArray(); - /*! - * \brief SetPointer - * \param p - */ void SetPointer(CBotVar* p) override; - - /*! - * \brief GetPointer - * \return - */ CBotVarClass* GetPointer() override; - /*! - * \brief Copy Copy a variable into another. - * \param pSrc - * \param bName - */ - void Copy(CBotVar* pSrc, bool bName=true) override; + void Copy(CBotVar* pSrc, bool bName = true) override; - /*! - * \brief GetItem Makes an element according to its numeric index enlarged - * the table if necessary if bExtend. - * \param n - * \param bGrow - * \return - */ - CBotVar* GetItem(int n, bool bGrow=false) override; - - /*! - * \brief GetItemList Gives the first item in the list. - * \return - */ + CBotVar* GetItem(int n, bool grow = false) override; CBotVar* GetItemList() override; - /*! - * \brief GetValString Gets the contents of the array into a string. - * \return - */ std::string GetValString() override; - /*! - * \brief Save1State - * \param pf - * \return - */ bool Save1State(FILE* pf) override; private: - //! Instance manager of table. + //! Array data CBotVarClass* m_pInstance; - //! My daddy is a buddy. - friend class CBotVar; }; diff --git a/src/CBot/CBotVar/CBotVarBoolean.cpp b/src/CBot/CBotVar/CBotVarBoolean.cpp index a06292f4..a0602b8d 100644 --- a/src/CBot/CBotVar/CBotVarBoolean.cpp +++ b/src/CBot/CBotVar/CBotVarBoolean.cpp @@ -17,16 +17,13 @@ * along with this program. If not, see http://gnu.org/licenses */ -// Modules inlcude #include "CBot/CBotVar/CBotVarBoolean.h" #include "CBot/CBotEnums.h" #include "CBot/CBotUtils.h" #include "CBot/CBotKeywordStrings.h" -// Local include - -// Global include +#include "CBot/CBotToken.h" //////////////////////////////////////////////////////////////////////////////// diff --git a/src/CBot/CBotVar/CBotVarBoolean.h b/src/CBot/CBotVar/CBotVarBoolean.h index 9ac52fe8..f78bf046 100644 --- a/src/CBot/CBotVar/CBotVarBoolean.h +++ b/src/CBot/CBotVar/CBotVarBoolean.h @@ -19,114 +19,35 @@ #pragma once -// Modules inlcude -#include "CBot/CBotToken.h" - #include "CBot/CBotVar/CBotVar.h" -// Local include - -// Global include - - -/*! - * \brief The CBotVarBoolean class Class for the management of boolean. +/** + * \brief CBotVar subclass for managing boolean values (::CBotTypBoolean) */ class CBotVarBoolean : public CBotVar { public: - - /*! - * \brief CBotVarBoolean - * \param name + /** + * \brief Constructor. Do not call directly, use CBotVar::Create() */ - CBotVarBoolean( const CBotToken* name ); + CBotVarBoolean(const CBotToken* name); - /*! - * \brief SetValInt - * \param val - * \param s - */ void SetValInt(int val, const std::string& s = nullptr) override; - - /*! - * \brief SetValFloat - * \param val - */ void SetValFloat(float val) override; - - /*! - * \brief GetValInt - * \return - */ int GetValInt() override; - - /*! - * \brief GetValFloat - * \return - */ float GetValFloat() override; - - /*! - * \brief GetValString - * \return - */ std::string GetValString() override; - /*! - * \brief Copy Copy a variable into another. - * \param pSrc - * \param bName - */ - void Copy(CBotVar* pSrc, bool bName=true) override; + void Copy(CBotVar* pSrc, bool bName = true) override; - /*! - * \brief And - * \param left - * \param right - */ void And(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Or - * \param left - * \param right - */ void Or(CBotVar* left, CBotVar* right) override; - - /*! - * \brief XOr - * \param left - * \param right - */ void XOr(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Not - */ void Not() override; - /*! - * \brief Eq - * \param left - * \param right - * \return - */ bool Eq(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Ne - * \param left - * \param right - * \return - */ bool Ne(CBotVar* left, CBotVar* right) override; - /*! - * \brief Save1State - * \param pf - * \return - */ bool Save1State(FILE* pf) override; private: diff --git a/src/CBot/CBotVar/CBotVarClass.cpp b/src/CBot/CBotVar/CBotVarClass.cpp index 4caa4c97..5f77fccb 100644 --- a/src/CBot/CBotVar/CBotVarClass.cpp +++ b/src/CBot/CBotVar/CBotVarClass.cpp @@ -159,13 +159,6 @@ void CBotVarClass::Copy(CBotVar* pSrc, bool bName) } } -//////////////////////////////////////////////////////////////////////////////// -void CBotVarClass::SetItemList(CBotVar* pVar) -{ - delete m_pVar; - m_pVar = pVar; // replaces the existing pointer -} - //////////////////////////////////////////////////////////////////////////////// void CBotVarClass::SetIdent(long n) { diff --git a/src/CBot/CBotVar/CBotVarClass.h b/src/CBot/CBotVar/CBotVarClass.h index 7d564d91..ee9a5416 100644 --- a/src/CBot/CBotVar/CBotVarClass.h +++ b/src/CBot/CBotVar/CBotVarClass.h @@ -19,175 +19,94 @@ #pragma once -// Modules inlcude #include "CBot/CBotVar/CBotVar.h" -// Local include - -// Global include - - -/*! - * \brief The CBotVarClass class Class management class instances. +/** + * \brief CBotVar subclass for managing classes (::CBotTypClass, ::CBotTypIntrinsic) + * + * \nosubgrouping */ class CBotVarClass : public CBotVar { public: - - /*! - * \brief CBotVarClass - * \param name - * \param type + /** + * \brief Constructor. Do not call directly, use CBotVar::Create() */ - CBotVarClass( const CBotToken* name, const CBotTypResult& type ); - - /*! - * \brief ~CBotVarClass + CBotVarClass(const CBotToken* name, const CBotTypResult& type); + /** + * \brief Destructor. Do not call directly, use CBotVar::Destroy() */ ~CBotVarClass(); - /*! - * \brief Copy Copy a variable into another. - * \param pSrc - * \param bName - */ - void Copy(CBotVar* pSrc, bool bName=true) override; + void Copy(CBotVar* pSrc, bool bName = true) override; - /*! - * \brief SetClass - * \param pClass - */ void SetClass(CBotClass* pClass) override; - - /*! - * \brief GetClass - * \return - */ CBotClass* GetClass() override; - /*! - * \brief GetItem Return an element of a class according to its name (*). - * \param name - * \return - */ CBotVar* GetItem(const std::string& name) override; - - /*! - * \brief GetItemRef - * \param nIdent - * \return - */ CBotVar* GetItemRef(int nIdent) override; - - /*! - * \brief GetItem For the management of an array. - * \param n - * \param bExtend can enlarge the table, but not beyond the threshold size - * of SetArray(). - * \return - */ CBotVar* GetItem(int n, bool bExtend) override; - - /*! - * \brief GetItemList - * \return - */ CBotVar* GetItemList() override; - - /*! - * \brief GetValString - * \return - */ std::string GetValString() override; - /*! - * \brief Save1State - * \param pf - * \return - */ bool Save1State(FILE* pf) override; - /*! - * \brief Maj - * \param pUser - * \param bContinue - */ void Maj(void* pUser, bool bContinue) override; - /*! - * \brief IncrementUse A reference to incrementation. + //! \name Reference counter + //@{ + + /** + * \brief Increment reference counter */ void IncrementUse(); - /*! - * \brief DecrementUse A reference to decrementation. + /** + * \brief Decrement reference counter */ void DecrementUse(); - /*! - * \brief GetPointer - * \return - */ + //@} + CBotVarClass* GetPointer() override; - /*! - * \brief SetItemList - * \param pVar - */ - void SetItemList(CBotVar* pVar); + //! \name Unique instance identifier + //@{ - /*! - * \brief SetIdent - * \param n - */ void SetIdent(long n) override; /*! - * \brief Find Makes an instance according to its unique number. - * \param id - * \return + * \brief Finds a class instance by unique identifier + * \param id Identifier to find + * \return Found class instance */ static CBotVarClass* Find(long id); - /*! - * \brief Eq - * \param left - * \param right - * \return - */ - bool Eq(CBotVar* left, CBotVar* right) override; + //@} - /*! - * \brief Ne - * \param left - * \param right - * \return - */ + bool Eq(CBotVar* left, CBotVar* right) override; bool Ne(CBotVar* left, CBotVar* right) override; - /*! - * \brief ConstructorSet - */ void ConstructorSet() override; private: - //! List of existing instances at some point. + //! Doubly linked list of all class instances - first static CBotVarClass* m_ExClass; - //! For this general list. + //! Doubly linked list of all class instances - next CBotVarClass* m_ExNext; - //! For this general list. + //! Doubly linked list of all class instances - previous CBotVarClass* m_ExPrev; - //! The class definition. + //! Class definition CBotClass* m_pClass; - //! The instance of a parent class. + //! Parent class instance CBotVarClass* m_pParent; - //! Contents. + //! Class members CBotVar* m_pVar; - //! Counter usage. + //! Reference counter int m_CptUse; - //! Identifier (unique) of an instance. + //! Identifier (unique) of an instance long m_ItemIdent; - //! Set if a constructor has been called. + //! Set after constructor is called, allows destructor to be called bool m_bConstructor; friend class CBotVar; diff --git a/src/CBot/CBotVar/CBotVarFloat.h b/src/CBot/CBotVar/CBotVarFloat.h index 7cff1e78..86f3dfc7 100644 --- a/src/CBot/CBotVar/CBotVarFloat.h +++ b/src/CBot/CBotVar/CBotVarFloat.h @@ -19,178 +19,45 @@ #pragma once -// Modules inlcude -#include #include "CBot/CBotVar/CBotVar.h" -// Local include - -// Global include - - -/*! - * \brief The CBotVarFloat class Class for managing real numbers (float). +/** + * \brief CBotVar subclass for managing float values (::CBotTypFloat) */ class CBotVarFloat : public CBotVar { public: - - /*! - * \brief CBotVarFloat - * \param name + /** + * \brief Constructor. Do not call directly, use CBotVar::Create() */ - CBotVarFloat( const CBotToken* name ); + CBotVarFloat(const CBotToken* name); - /*! - * \brief SetValInt - * \param val - * \param s - */ void SetValInt(int val, const std::string& s = nullptr) override; - - /*! - * \brief SetValFloat - * \param val - */ void SetValFloat(float val) override; - - /*! - * \brief GetValInt - * \return - */ int GetValInt() override; - - /*! - * \brief GetValFloat - * \return - */ float GetValFloat() override; - - /*! - * \brief GetValString - * \return - */ std::string GetValString() override; - /*! - * \brief Copy Copy a variable into another. - * \param pSrc - * \param bName - */ - void Copy(CBotVar* pSrc, bool bName=true) override; + void Copy(CBotVar* pSrc, bool bName = true) override; - /*! - * \brief Add Addition. - * \param left - * \param right - */ void Add(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Sub Substraction. - * \param left - * \param right - */ void Sub(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Mul Multiplication. - * \param left - * \param right - */ void Mul(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Div Division. - * \param left - * \param right - * \return - */ CBotError Div(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Modulo Remainder of division. - * \param left - * \param right - * \return - */ CBotError Modulo(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Power - * \param left - * \param right - */ void Power(CBotVar* left, CBotVar* right) override; - /*! - * \brief Lo - * \param left - * \param right - * \return - */ bool Lo(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Hi - * \param left - * \param right - * \return - */ bool Hi(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Ls - * \param left - * \param right - * \return - */ bool Ls(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Hs - * \param left - * \param right - * \return - */ bool Hs(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Eq - * \param left - * \param right - * \return - */ bool Eq(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Ne - * \param left - * \param right - * \return - */ bool Ne(CBotVar* left, CBotVar* right) override; - /*! - * \brief Neg - */ void Neg() override; - - /*! - * \brief Inc - */ void Inc() override; - - /*! - * \brief Dec - */ void Dec() override; - /*! - * \brief Save1State - * \param pf - * \return - */ bool Save1State(FILE* pf) override; private: diff --git a/src/CBot/CBotVar/CBotVarInt.h b/src/CBot/CBotVar/CBotVarInt.h index 9cce4e9b..3080189b 100644 --- a/src/CBot/CBotVar/CBotVarInt.h +++ b/src/CBot/CBotVar/CBotVarInt.h @@ -19,232 +19,55 @@ #pragma once -// Modules inlcude -#include #include "CBot/CBotVar/CBotVar.h" -// Local include - -// Global include - - -/*! - * \brief The CBotVarInt class Class for the management of integer numbers (int). +/** + * \brief CBotVar subclass for managing integer values (::CBotTypInt) */ class CBotVarInt : public CBotVar { public: - - /*! - * \brief CBotVarInt - * \param name + /** + * \brief Constructor. Do not call directly, use CBotVar::Create() */ - CBotVarInt( const CBotToken* name ); + CBotVarInt(const CBotToken* name); - /*! - * \brief SetValInt - * \param val - * \param s - */ - void SetValInt(int val, const std::string& s = nullptr) override; - - /*! - * \brief SetValFloat - * \param val - */ + void SetValInt(int val, const std::string& s = "") override; void SetValFloat(float val) override; - - /*! - * \brief GetValInt - * \return - */ int GetValInt() override; - - /*! - * \brief GetValFloat - * \return - */ float GetValFloat() override; - - /*! - * \brief GetValString - * \return - */ std::string GetValString() override; - /*! - * \brief Copy Copy a variable in to another. - * \param pSrc - * \param bName - */ - void Copy(CBotVar* pSrc, bool bName=true) override; + void Copy(CBotVar* pSrc, bool bName = true) override; - /*! - * \brief Add - * \param left - * \param right - */ void Add(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Sub - * \param left - * \param right - */ void Sub(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Mul - * \param left - * \param right - */ void Mul(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Div - * \param left - * \param right - * \return - */ CBotError Div(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Modulo - * \param left - * \param right - * \return - */ CBotError Modulo(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Power - * \param left - * \param right - */ void Power(CBotVar* left, CBotVar* right) override; - /*! - * \brief Lo - * \param left - * \param right - * \return - */ bool Lo(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Hi - * \param left - * \param right - * \return - */ bool Hi(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Ls - * \param left - * \param right - * \return - */ bool Ls(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Hs - * \param left - * \param right - * \return - */ bool Hs(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Eq - * \param left - * \param right - * \return - */ bool Eq(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Ne - * \param left - * \param right - * \return - */ bool Ne(CBotVar* left, CBotVar* right) override; - /*! - * \brief XOr - * \param left - * \param right - */ void XOr(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Or - * \param left - * \param right - */ void Or(CBotVar* left, CBotVar* right) override; - - /*! - * \brief And - * \param left - * \param right - */ void And(CBotVar* left, CBotVar* right) override; - - /*! - * \brief SL - * \param left - * \param right - */ - void SL(CBotVar* left, CBotVar* right) override; - - /*! - * \brief SR - * \param left - * \param right - */ - void SR(CBotVar* left, CBotVar* right) override; - - /*! - * \brief ASR - * \param left - * \param right - */ - void ASR(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Neg - */ - void Neg() override; - - /*! - * \brief Not - */ void Not() override; - /*! - * \brief Inc - */ - void Inc() override; + void SL(CBotVar* left, CBotVar* right) override; + void SR(CBotVar* left, CBotVar* right) override; + void ASR(CBotVar* left, CBotVar* right) override; - /*! - * \brief Dec - */ + void Neg() override; + void Inc() override; void Dec() override; - /*! - * \brief Save0State - * \param pf - * \return - */ bool Save0State(FILE* pf) override; - - /*! - * \brief Save1State - * \param pf - * \return - */ bool Save1State(FILE* pf) override; private: diff --git a/src/CBot/CBotVar/CBotVarPointer.h b/src/CBot/CBotVar/CBotVarPointer.h index c7800bcb..276e4e84 100644 --- a/src/CBot/CBotVar/CBotVarPointer.h +++ b/src/CBot/CBotVar/CBotVarPointer.h @@ -19,142 +19,56 @@ #pragma once -// Modules inlcude #include "CBot/CBotVar/CBotVar.h" -// Local include - -// Global include - - -/*! - * \brief The CBotVarPointer class Class for the management of pointers to a - * class instances. +/** + * \brief CBotVar subclass for managing pointers to classes (::CBotTypPointer) */ class CBotVarPointer : public CBotVar { public: - - /*! - * \brief CBotVarPointer - * \param name - * \param type + /** + * \brief Constructor. Do not call directly, use CBotVar::Create() */ - CBotVarPointer( const CBotToken* name, CBotTypResult& type ); - - /*! - * \brief ~CBotVarPointer + CBotVarPointer(const CBotToken* name, CBotTypResult& type); + /** + * \brief Destructor. Do not call directly, use CBotVar::Destroy() */ ~CBotVarPointer(); - /*! - * \brief Copy Copy a variable into another. - * \param pSrc - * \param bName - */ - void Copy(CBotVar* pSrc, bool bName=true) override; + void Copy(CBotVar* pSrc, bool bName = true) override; - /*! - * \brief SetClass - * \param pClass - */ void SetClass(CBotClass* pClass) override; - - /*! - * \brief GetClass - * \return - */ CBotClass* GetClass() override; - /*! - * \brief GetItem Return an element of a class according to its name (*). - * \param name - * \return - */ CBotVar* GetItem(const std::string& name) override; - - /*! - * \brief GetItemRef - * \param nIdent - * \return - */ CBotVar* GetItemRef(int nIdent) override; - - /*! - * \brief GetItemList - * \return - */ CBotVar* GetItemList() override; - - /*! - * \brief GetValString - * \return - */ std::string GetValString() override; - /*! - * \brief SetPointer Initializes the pointer to the instance of a class. - * \param p - */ void SetPointer(CBotVar* p) override; - - /*! - * \brief GetPointer - * \return - */ CBotVarClass* GetPointer() override; - /*! - * \brief SetIdent Associates an identification number (unique). - * \param n - */ void SetIdent(long n) override; - - /*! - * \brief GetIdent Gives the identification number associated with. - * \return + /** + * \brief Returns the unique instance identifier + * \see SetIdent() */ long GetIdent(); - /*! - * \brief ConstructorSet - */ void ConstructorSet() override; - /*! - * \brief Save1State - * \param pf - * \return - */ bool Save1State(FILE* pf) override; - /*! - * \brief Maj - * \param pUser - * \param bContinue - */ void Maj(void* pUser, bool bContinue) override; - /*! - * \brief Eq - * \param left - * \param right - * \return - */ bool Eq(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Ne - * \param left - * \param right - * \return - */ bool Ne(CBotVar* left, CBotVar* right) override; private: - //! Contents. + //! Class pointed to CBotVarClass* m_pVarClass; - //! Class provided for this pointer. + //! Class type CBotClass* m_pClass; friend class CBotVar; }; diff --git a/src/CBot/CBotVar/CBotVarString.cpp b/src/CBot/CBotVar/CBotVarString.cpp index 931c6102..0dee1c5e 100644 --- a/src/CBot/CBotVar/CBotVarString.cpp +++ b/src/CBot/CBotVar/CBotVarString.cpp @@ -65,9 +65,9 @@ void CBotVarString::Copy(CBotVar* pSrc, bool bName) } //////////////////////////////////////////////////////////////////////////////// -void CBotVarString::SetValString(const std::string& p) +void CBotVarString::SetValString(const std::string& val) { - m_val = p; + m_val = val; m_binit = CBotVar::InitType::DEF; } diff --git a/src/CBot/CBotVar/CBotVarString.h b/src/CBot/CBotVar/CBotVarString.h index b291c5e8..f0c9105b 100644 --- a/src/CBot/CBotVar/CBotVarString.h +++ b/src/CBot/CBotVar/CBotVarString.h @@ -19,106 +19,33 @@ #pragma once -// Modules inlcude #include "CBot/CBotVar/CBotVar.h" -// Local include - -// Global include - - -/*! - * \brief The CBotVarString class Class for management of strings (String). +/** + * \brief CBotVar subclass for managing string values (::CBotTypString) */ class CBotVarString : public CBotVar { public: - - /*! - * \brief CBotVarString - * \param name + /** + * \brief Constructor. Do not call directly, use CBotVar::Create() */ - CBotVarString( const CBotToken* name ); + CBotVarString(const CBotToken* name); - /*! - * \brief SetValString - * \param p - */ - void SetValString(const std::string& p) override; - - /*! - * \brief GetValString - * \return - */ + void SetValString(const std::string& val) override; std::string GetValString() override; - /*! - * \brief Copy Copy a variable into another. - * \param pSrc - * \param bName - */ - void Copy(CBotVar* pSrc, bool bName=true) override; + void Copy(CBotVar* pSrc, bool bName = true) override; - /*! - * \brief Add - * \param left - * \param right - */ void Add(CBotVar* left, CBotVar* right) override; - /*! - * \brief Lo - * \param left - * \param right - * \return - */ bool Lo(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Hi - * \param left - * \param right - * \return - */ bool Hi(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Ls - * \param left - * \param right - * \return - */ bool Ls(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Hs - * \param left - * \param right - * \return - */ bool Hs(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Eq - * \param left - * \param right - * \return - */ bool Eq(CBotVar* left, CBotVar* right) override; - - /*! - * \brief Ne - * \param left - * \param right - * \return - */ bool Ne(CBotVar* left, CBotVar* right) override; - /*! - * \brief Save1State - * \param pf - * \return - */ bool Save1State(FILE* pf) override; private: