TS_InterfaceSafe

 (Available in 01 TS COM - TS_COM_InterfaceSafe)

Purpose

Place holder for COM interface pointers

Syntax

oInterfaceSafe:=TS_InterfaceSafe{ [oOwner], oAIUnknown | pAIUnknown, TRUE }

Access methods

FInit - Test if the enclosed interface is valid
IsValidObject - Test if the object is 'Valid'
AIDispatch - Get ( if availabe ) the 'AbstractIDispatch'-interface of the contained object
AIUnknown - Get ( if availabe ) the 'AbstractIUnknown'-interface of the contained object
AIThis - Get ( if availabe ) the 'AbstractISelf'-interface of the contained object
AITypeLib - Get ( if availabe ) the 'AbstractITypeLib'-interface of the contained object
VT -

Methods

TSTraceInfo -
INIT - Safe for interface object and pointers
NEW - CALLBACK: New ( OnInited event )
Destroy - CALLBACK: It is adviced to use 'oObject:Axit()'
QueryInterface - CALLBACK: Query the COM interface
AGetInterface - Get a interface from the enclosed COM object
RegisterAxit - Tell the GC to call the 'Axit' method

Description

This objectec is used to provide a wrapper that isolates the interface from the application code. In this way the application is not concerned with proper ref-counting and/or de-allocation of the interface object when needed.

Inherits from

TS_Root1

Example

oInterfaceSafe:=TS_InterfaceSafe{ oOwner, PTR( _CAST, LONG( pstruWinVariantArg.uVariant.ppDispVal  ; ...
...) ), TRUE }
IF oInterfaceSafe:FInit
   DO CASE
   CASE symClass==NULL_SYMBOL
      uRetVal:=TS_DelegateIDispatch{ oOwner, oInterfaceSafe }
   CASE TS_IsClassOfClass( symClass, #TS_DelegateIDispatch )
      uRetVal:=CreateInstance( symClass, oOwner, oInterfaceSafe )
      TSTrace SetCreatedAt uRetVal
   CASE TS_IsClassOfClass( symClass, #TS_DelegateIDispatchAuto )
      uRetVal:=CreateInstance( symClass, oOwner, oInterfaceSafe )
      TSTrace SetCreatedAt uRetVal
   OTHERWISE
      TSTrace Warning "!TS_IsClassOfClass(symClass,oOwner,#TS_DelegateIDispatch)"
      uRetVal:=TS_DelegateIDispatch{ oOwner, oInterfaceSafe }
   END
   IF !( IsObject( uRetVal ) .AND. uRetVal<>NULL_OBJECT .AND. uRetVal:IsValidObject  ; ...
  ... )
      TSTrace Warning "!(IsObject(uRetVal) .AND. uRetVal<>NULL_OBJECT .AND. uRetVal" ; ...
     ... +":IsValidObject)"
      IF IsObject( uRetVal ) .AND. uRetVal<>NULL_OBJECT
         DO CASE
         CASE IsMethod( uRetVal, #Axit )
            Send( uRetVal, #Axit )
         CASE IsMethod( uRetVal, #Destroy )
            Send( uRetVal, #Destroy )
         OTHERWISE
            TSTrace Warning "!IsMethod(uRetVal,#Axit) .AND. !IsMethod(uRetVal,#Destroy)"
         END
      END
      uRetVal:=NIL
   END
ELSE
   TSTrace Warning "!TS_InterfaceSafe{oOwner,PTR(_CAST,LONG(pstruWinVariantArg.uVariant" ; ...
  ... +".ppDispVal)),TRUE}:FInit"
   uRetVal:=NIL
END
oInterfaceSafe:Axit( )
oInterfaceSafe:=NULL_OBJECT

Source

CLASS TS_InterfaceSafe INHERIT TS_Root1
   DECLARE ACCESS AIDispatch
   DECLARE ACCESS AIThis
   DECLARE ACCESS AITypeLib
   DECLARE ACCESS AIUnknown
   DECLARE ACCESS FInit
   DECLARE ACCESS VT
   DECLARE METHOD AGetInterface
   DECLARE METHOD QueryInterface