/* $DOC$ $AUTHOR$ Copyright 1999-2000 Chen Kedem $TEMPLATE$ Function $NAME$ __objHasData() $CATEGORY$ API $SUBCATEGORY$ Objects $ONELINER$ Determine whether a symbol exist in object as VAR $SYNTAX$ __objHasData( , ) --> lExist $ARGUMENTS$ is an object to scan. is the name of the symbol to look for. $RETURNS$ __objHasData() return .T. if the given exist as VAR (instance variable) in object .T. ? __objHasData( oB, "lBugFree" ) // --> .F. ? __objHasData( oB, "Left" ) // --> .F. since this is a METHOD $STATUS$ R $COMPLIANCE$ H $FILES$ Library is core $SEEALSO$ __objGetMethodList(), __objGetMsgList(), __objHasMethod() $END$ */ /* $DOC$ $AUTHOR$ Copyright 1999-2000 Chen Kedem $TEMPLATE$ Function $NAME$ __objHasMethod() $CATEGORY$ API $SUBCATEGORY$ Objects $ONELINER$ Determine whether a symbol exist in object as METHOD $SYNTAX$ __objHasMethod( , ) --> lExist $ARGUMENTS$ is an object to scan. is the name of the symbol to look for. $RETURNS$ __objHasMethod() return .T. if the given exist as METHOD (class function) in object .F. since this is a VAR ? __objHasMethod( oB, "FixBugs" ) // --> .F. ? __objHasMethod( oB, "Left" ) // --> .T. $STATUS$ R $COMPLIANCE$ H $FILES$ Library is core $SEEALSO$ __objGetMethodList(), __objGetMsgList(), __objHasData() $END$ */ /* $DOC$ $AUTHOR$ Copyright 1999-2000 Chen Kedem $TEMPLATE$ Function $NAME$ __objGetMsgList() $CATEGORY$ API $SUBCATEGORY$ Objects $ONELINER$ Return names of all VAR or METHOD for a given object $SYNTAX$ __objGetMsgList( , [], [nClassType] ) --> aNames $ARGUMENTS$ is an object to scan. is an optional logical value that specifies the information to return. A value of .T. instruct the function to return list of all VAR names, .F. return list of all METHOD names. Default value is .T. is on optional numeric code for selecting which class type to return. Default value is HB_MSGLISTALL, returning the whole list. $RETURNS$ __objGetMsgList() return an array of character stings with all VAR names or all METHOD names for a given object. __objGetMsgList() would return an empty array {} if the given object does not contain the requested information. $DESCRIPTION$ __objGetMsgList() is a low-level class support function that let you find all instance variable or method names for a given object. If specified, the following table shows the values for that allow you to distinguish between VAR and CLASS VAR: hboo.ch Meaning HB_MSGLISTALL All types HB_MSGLISTCLASS CLASS VAR only HB_MSGLISTPURE VAR only
VAR are instance variable usable within each object from a class, where each object has its own VARs. CLASS VAR are shared by all objects from a Class, so the changed value within Object1 will be reflected when accessing the CLASS VAR from Object2. $EXAMPLES$ #include "hboo.ch" // show information about TBrowse class LOCAL oB := TBrowseNew( 0, 0, 24, 79 ), tmp FOR EACH tmp IN __objGetMsgList( oB, .T. ) ? "VAR name:", tmp NEXT FOR EACH tmp IN __objGetMsgList( oB, .T., HB_MSGLISTCLASS ) ? "CLASS VAR name:", tmp NEXT FOR EACH tmp IN __objGetMsgList( oB, .F. ) ? "METHOD name:", tmp NEXT $STATUS$ R $COMPLIANCE$ H $FILES$ Header file is hboo.ch Library is core $SEEALSO$ __objGetMethodList(), __objGetValueList(), __objHasData(), __objHasMethod() $END$ */ /* $DOC$ $AUTHOR$ Copyright 1999-2000 Chen Kedem $TEMPLATE$ Function $NAME$ __objGetMethodList() $CATEGORY$ API $SUBCATEGORY$ Objects $ONELINER$ Return names of all METHOD for a given object $SYNTAX$ __objGetMethodList( ) --> aMethodNames $ARGUMENTS$ is an object to scan. $RETURNS$ __objGetMethodList() return an array of character stings with all METHOD names for a given object. __objGetMethodList() would return an empty array {} if the given object does not contain any METHOD. $DESCRIPTION$ __objGetMethodList() is a low-level class support function that let you find all class functions names for a given object. It is equivalent to `__objGetMsgList( oObject, .F. )`. $EXAMPLES$ // show information about TBrowse class LOCAL oB := TBrowseNew( 0, 0, 24, 79 ), tmp FOR EACH tmp IN __objGetMethodList( oB ) ? "METHOD name:", tmp NEXT $STATUS$ R $COMPLIANCE$ H $FILES$ Library is core $SEEALSO$ __objGetMsgList(), __objGetValueList(), __objHasData(), __objHasMethod() $END$ */ /* $DOC$ $AUTHOR$ Copyright 1999-2000 Chen Kedem $TEMPLATE$ Function $NAME$ __objGetValueList() $CATEGORY$ API $SUBCATEGORY$ Objects $ONELINER$ Return an array of VAR names and values for a given object $SYNTAX$ __objGetValueList( , [] ) --> aData $ARGUMENTS$ is an object to scan. is an optional array with VAR names you want to exclude from the scan. $RETURNS$ __objGetValueList() return a 2D array that contain pairs of a VAR symbol name and the value of VAR. __objGetValueList() would return an empty array {} if the given object does not contain the requested information. $DESCRIPTION$ __objGetValueList() is a low-level class support function that return an array with VAR names and value, each array element is a pair of: `aData[ i ][ HB_OO_DATA_SYMBOL ]` contain the symbol name `aData[ i ][ HB_OO_DATA_VALUE ]` contain the value of VAR $EXAMPLES$ // FIXME // show information about TBrowse class #include "hboo.ch" LOCAL oB := TBrowseNew( 0, 0, 24, 79 ), tmp FOR EACH tmp IN __objGetValueList( oB ) ? ; "VAR name:", tmp[ HB_OO_DATA_SYMBOL ], ; " value=", tmp[ HB_OO_DATA_VALUE ] NEXT $STATUS$ R $COMPLIANCE$ H $FILES$ Header file is hboo.ch Library is core $SEEALSO$ __objGetMethodList(), __objGetMsgList(), __objHasData(), __objHasMethod(), __objSetValueList() $END$ */ /* $DOC$ $AUTHOR$ Copyright 1999-2000 Chen Kedem $TEMPLATE$ Function $NAME$ __objSetValueList() $CATEGORY$ API $SUBCATEGORY$ Objects $ONELINER$ Set object with an array of VAR names and values $SYNTAX$ __objSetValueList( , ) --> oObject $ARGUMENTS$ is an object to set. is a 2D array with a pair of instance variables and values for setting those variable. $RETURNS$ __objSetValueList() return a reference to . $DESCRIPTION$ __objSetValueList() is a low-level class support function that let you set a group of instance variables with values. each array element in is a pair of: aData[ i ][ HB_OO_DATA_SYMBOL ] which contain the variable name to set aData[ i ][ HB_OO_DATA_VALUE ] contain the new variable value. $EXAMPLES$ // set some TBrowse instance variable #include "hboo.ch" LOCAL oB := TBrowse():New() LOCAL aData := Array( 4, 2 ) aData[ 1 ][ HB_OO_DATA_SYMBOL ] := "nTop" aData[ 1 ][ HB_OO_DATA_VALUE ] := 1 aData[ 2 ][ HB_OO_DATA_SYMBOL ] := "nLeft" aData[ 2 ][ HB_OO_DATA_VALUE ] := 10 aData[ 3 ][ HB_OO_DATA_SYMBOL ] := "nBottom" aData[ 3 ][ HB_OO_DATA_VALUE ] := 20 aData[ 4 ][ HB_OO_DATA_SYMBOL ] := "nRight" aData[ 4 ][ HB_OO_DATA_VALUE ] := 70 __objSetValueList( oB, aData ) ? oB:nTop // --> 1 ? oB:nLeft // --> 10 ? oB:nBottom // --> 20 ? oB:nRight // --> 70 $STATUS$ R $COMPLIANCE$ H $FILES$ Header file is hboo.ch Library is core $SEEALSO$ __objGetValueList() $END$ */ /* $DOC$ $AUTHOR$ Copyright 1999-2000 Chen Kedem $TEMPLATE$ Function $NAME$ __objAddMethod() $CATEGORY$ API $SUBCATEGORY$ Objects $ONELINER$ Add a METHOD to an already existing class $SYNTAX$ __objAddMethod( , , ) --> oObject $ARGUMENTS$ is the object to work on. is the symbol name of the new METHOD to add. is a pointer to a function to associate with the method. $RETURNS$ __objAddMethod() return a reference to . $DESCRIPTION$ __objAddMethod() is a low-level class support function that add a new METHOD to an object. is unchanged if a symbol with the name already exist in . Note that is a special pointer to a function that was created using the @ operator, see example below. $EXAMPLES$ // create a new THappy class and add a Smile method LOCAL oHappy := HBClass():New( "THappy" ) __objAddMethod( oHappy, "Smile", @MySmile() ) ? oHappy:Smile( 1 ) // --> :) ? oHappy:Smile( 2 ) // --> ;) ? oHappy:Smile( 3 ) // --> *SMILE* STATIC FUNCTION MySmile( nType ) IF HB_ISNUMERIC( nType ) SWITCH nType CASE 1 ; RETURN ":)" CASE 2 ; RETURN ";)" CASE 3 ; RETURN "*SMILE*" ENDSWITCH ENDIF RETURN NIL $STATUS$ R $COMPLIANCE$ H $FILES$ Library is core $SEEALSO$ __objAddInline(), __objAddData(), __objDelMethod(), __objGetMethodList(), __objGetMsgList(), __objHasMethod(), __objModMethod() $END$ */ /* $DOC$ $AUTHOR$ Copyright 1999-2000 Chen Kedem $TEMPLATE$ Function $NAME$ __objAddInline() $CATEGORY$ API $SUBCATEGORY$ Objects $ONELINER$ Add an INLINE to an already existing class $SYNTAX$ __objAddInline( , , ) --> oObject $ARGUMENTS$ is the object to work on. is the symbol name of the new INLINE to add. is a code block to associate with the INLINE method. $RETURNS$ __objAddInline() return a reference to . $DESCRIPTION$ __objAddInline() is a low-level class support function that add a new INLINE method to an object. is unchanged if a symbol with the name already exist in . $EXAMPLES$ // create a new THappy class and add a Smile INLINE method LOCAL oHappy := HBClass():New( "THappy" ) LOCAL bInline := {| Self, nType | HB_SYMBOL_UNUSED( Self ), ; { ":)", ";)", "*SMILE*" }[ nType ] } __objAddInline( oHappy, "Smile", bInline ) ? oHappy:Smile( 1 ) // --> :) ? oHappy:Smile( 2 ) // --> ;) ? oHappy:Smile( 3 ) // --> *SMILE* $STATUS$ R $COMPLIANCE$ H $FILES$ Library is core $SEEALSO$ __objAddData(), __objAddMethod(), __objDelInline(), __objGetMethodList(), __objGetMsgList(), __objHasMethod(), __objModInline() $END$ */ /* $DOC$ $AUTHOR$ Copyright 1999-2000 Chen Kedem $TEMPLATE$ Function $NAME$ __objAddData() $CATEGORY$ API $SUBCATEGORY$ Objects $ONELINER$ Add a VAR to an already existing class $SYNTAX$ __objAddData( , ) --> oObject $ARGUMENTS$ is the object to work on. is the symbol name of the new VAR to add. $RETURNS$ __objAddData() return a reference to . $DESCRIPTION$ __objAddData() is a low-level class support function that add a new VAR to an object. is unchanged if a symbol with the name already exist in . $EXAMPLES$ // create a new THappy class and add a lHappy VAR LOCAL oHappy := HBClass():New( "THappy" ) __objAddData( oHappy, "lHappy" ) oHappy:lHappy := .T. IF oHappy:lHappy ? "Happy, Happy, Joy, Joy !!!" ELSE ? ":(..." ENDIF $STATUS$ R $COMPLIANCE$ H $FILES$ Library is core $SEEALSO$ __objAddInline(), __objAddMethod(), __objDelData(), __objGetMsgList(), __objGetValueList(), __objHasData(), __objSetValueList() $END$ */ /* $DOC$ $AUTHOR$ Copyright 1999-2000 Chen Kedem $TEMPLATE$ Function $NAME$ __objModMethod() $CATEGORY$ API $SUBCATEGORY$ Objects $ONELINER$ Modify (replace) a METHOD in an already existing class $SYNTAX$ __objModMethod( , , ) --> oObject $ARGUMENTS$ is the object to work on. is the symbol name of the METHOD to modify. is a pointer to a new function to associate with the method. $RETURNS$ __objModMethod() return a reference to . $DESCRIPTION$ __objModMethod() is a low-level class support function that modify a METHOD in an object and replace it with a new function. is unchanged if a symbol with the name does not exist in . __objModMethod() is used in inheritance mechanism. Note that is a special pointer to a function that was created using the @ operator, see example below. $EXAMPLES$ // create a new THappy class and add a Smile method LOCAL oHappy := HBClass():New( "THappy" ) __objAddMethod( oHappy, "Smile", @MySmile() ) ? oHappy:Smile( 1 ) // --> :) ? oHappy:Smile( 2 ) // --> ;) // replace Smile method with a new function __objAddMethod( oHappy, "Smile", @YourSmile() ) ? oHappy:Smile( 1 ) // --> *SMILE* ? oHappy:Smile( 2 ) // --> *WINK* STATIC FUNCTION MySmile( nType ) DO CASE CASE nType == 1 RETURN ":)" CASE nType == 2 RETURN ";)" ENDCASE RETURN NIL STATIC FUNCTION YourSmile( nType ) DO CASE CASE nType == 1 RETURN "*SMILE*" CASE nType == 2 RETURN "*WINK*" ENDCASE RETURN NIL $STATUS$ R $COMPLIANCE$ H $FILES$ Library is core $SEEALSO$ __objAddMethod(), __objDelMethod(), __objGetMethodList(), __objGetMsgList(), __objHasMethod() $END$ */ /* $DOC$ $AUTHOR$ Copyright 1999-2000 Chen Kedem $TEMPLATE$ Function $NAME$ __objModInline() $CATEGORY$ API $SUBCATEGORY$ Objects $ONELINER$ Modify (replace) an INLINE method in an already existing class $SYNTAX$ __objModInline( , , ) --> oObject $ARGUMENTS$ is the object to work on. is the symbol name of the INLINE method to modify. is a new code block to associate with the INLINE method. $RETURNS$ __objModInline() return a reference to . $DESCRIPTION$ __objModInline() is a low-level class support function that modify an INLINE method in an object and replace it with a new code block. is unchanged if a symbol with the name does not exist in . __objModInline() is used in inheritance mechanism. $EXAMPLES$ // create a new THappy class and add a Smile INLINE method LOCAL oHappy := HBClass():New( "THappy" ) LOCAL bMyInline := {| Self, nType | HB_SYMBOL_UNUSED( Self ), ; { ":)", ";)" }[ nType ] } LOCAL bYourInline := {| Self, nType | HB_SYMBOL_UNUSED( Self ), ; { "*SMILE*", "*WINK*" }[ nType ] } __objAddInline( oHappy, "Smile", bMyInline ) ? oHappy:Smile( 1 ) // --> :) ? oHappy:Smile( 2 ) // --> ;) // replace Smile inline method with a new code block __objModInline( oHappy, "Smile", bYourInline ) ? oHappy:Smile( 1 ) // --> *SMILE* ? oHappy:Smile( 2 ) // --> *WINK* $STATUS$ R $COMPLIANCE$ H $FILES$ Library is core $SEEALSO$ __objAddInline(), __objDelInline(), __objGetMethodList(), __objGetMsgList(), __objHasMethod() $END$ */ /* $DOC$ $AUTHOR$ Copyright 1999-2000 Chen Kedem $TEMPLATE$ Function $NAME$ __objDelMethod() $CATEGORY$ API $SUBCATEGORY$ Objects $ONELINER$ Delete a METHOD from class $SYNTAX$ __objDelMethod( , ) --> oObject $ARGUMENTS$ is the object to work on. is the symbol name of METHOD or INLINE method to be deleted (removed) from the object. $RETURNS$ __objDelMethod() return a reference to . $DESCRIPTION$ __objDelMethod() is a low-level class support function that deletes (removes) a METHOD or an INLINE method from an object. is unchanged if a symbol with the name does not exist in . __objDelInline() is exactly the same as __objDelMethod(). $EXAMPLES$ // create a new THappy class and add a Smile method LOCAL oHappy := HBClass():New( "THappy" ) __objAddMethod( oHappy, "Smile", @MySmile() ) ? __objHasMethod( oHappy, "Smile" ) // --> .T. // remove Smile method __objDelMethod( oHappy, "Smile" ) ? __objHasMethod( oHappy, "Smile" ) // --> .F. STATIC FUNCTION MySmile( nType ) DO CASE CASE nType == 1 RETURN ":)" CASE nType == 2 RETURN ";)" ENDCASE RETURN NIL $STATUS$ R $COMPLIANCE$ H $FILES$ Library is core $SEEALSO$ __objAddInline(), __objAddMethod(), __objGetMethodList(), __objGetMsgList(), __objHasMethod(), __objModInline(), __objModMethod() $END$ */ /* $DOC$ $AUTHOR$ Copyright 1999-2000 Chen Kedem $TEMPLATE$ Function $NAME$ __objDelInline() $CATEGORY$ API $SUBCATEGORY$ Objects $ONELINER$ Delete a METHOD INLINE from class $SYNTAX$ __objDelInline( , ) --> oObject $ARGUMENTS$ is the object to work on. is the symbol name of METHOD or INLINE method to be deleted (removed) from the object. $RETURNS$ __objDelInline() return a reference to . $DESCRIPTION$ __objDelInline() is a low-level class support function that delete (remove) a METHOD or an INLINE method from an object. is unchanged if a symbol with the name does not exist in . $EXAMPLES$ // create a new THappy class and add a Smile method LOCAL oHappy := HBClass():New( "THappy" ) __objAddMethod( oHappy, "Smile", @MySmile() ) ? __objHasMethod( oHappy, "Smile" ) // --> .T. // remove Smile method __objDelInline( oHappy, "Smile" ) ? __objHasMethod( oHappy, "Smile" ) // --> .F. STATIC FUNCTION MySmile( nType ) DO CASE CASE nType == 1 RETURN ":)" CASE nType == 2 RETURN ";)" ENDCASE RETURN NIL $STATUS$ R $COMPLIANCE$ H $FILES$ Library is core $SEEALSO$ __objAddInline(), __objAddMethod(), __objGetMethodList(), __objGetMsgList(), __objHasMethod(), __objModInline(), __objModMethod() $END$ */ /* $DOC$ $AUTHOR$ Copyright 1999-2000 Chen Kedem $TEMPLATE$ Function $NAME$ __objDelData() $CATEGORY$ API $SUBCATEGORY$ Objects $ONELINER$ Delete a VAR (instance variable) from class $SYNTAX$ __objDelMethod( , ) --> oObject $ARGUMENTS$ is the object to work on. is the symbol name of VAR to be deleted (removed) from the object. $RETURNS$ __objDelData() return a reference to . $DESCRIPTION$ __objDelData() is a low-level class support function that delete (remove) a VAR from an object. is unchanged if a symbol with the name does not exist in . $EXAMPLES$ // create a new THappy class and add a lHappy VAR LOCAL oHappy := HBClass():New( "THappy" ) __objAddData( oHappy, "lHappy" ) ? __objHasData( oHappy, "lHappy" ) // --> .T. // remove lHappy VAR __objDelData( oHappy, "lHappy" ) ? __objHasData( oHappy, "lHappy" ) // --> .F. $STATUS$ R $COMPLIANCE$ H $FILES$ Library is core $SEEALSO$ __objAddData(), __objGetMsgList(), __objGetValueList(), __objHasData(), __objSetValueList() $END$ */ /* $DOC$ $AUTHOR$ Copyright 1999-2000 Chen Kedem $TEMPLATE$ Function $NAME$ __objDerivedFrom() $CATEGORY$ API $SUBCATEGORY$ Objects $ONELINER$ Determine whether a class is derived from another class $SYNTAX$ __objDerivedFrom( , ) --> lIsParent $ARGUMENTS$ is the object to check. is the object that may be a parent. can be either an Object or a Character string with the class name. $RETURNS$ __objDerivedFrom() return a logical TRUE (.T.) if is derived from . $DESCRIPTION$ __objDerivedFrom() is a low-level class support function that check is one class is a super class of the other, or in other words, does class a child or descendant of . $EXAMPLES$ // Create three classes and check their relations #include "hbclass.ch" PROCEDURE Main() LOCAL oSuper := TMood():New() LOCAL oObject := THappy():New() LOCAL oDress := TShirt():New() ? __objDerivedFrom( oObject, oSuper ) // --> .T. ? __objDerivedFrom( oSuper, oObject ) // --> .F. ? __objDerivedFrom( oObject, oDress ) // --> .F. RETURN CREATE CLASS TMood METHOD New() INLINE Self ENDCLASS CREATE CLASS THappy INHERIT TMood METHOD Smile() INLINE QOut( "*smile*" ) ENDCLASS CREATE CLASS TShirt VAR Color VAR Size METHOD New() INLINE Self ENDCLASS $STATUS$ R $COMPLIANCE$ H $FILES$ Library is core $SEEALSO$ __objHasData(), __objHasMethod() $END$ */