theConfig 10.0
Loading...
Searching...
No Matches
Callback Signature List

List of all callback defined by tcllcconfig

The callback is a regular TCL proc that either stands alone or is part of a class.

callback resolution
The callback is a list of arguments: [list ?instance|class? callback args...]
  1. If the first argument is a class than it is a class-callback.
  2. If the first argument is an instance than it is a instance-callback.
  3. If the first argument is not a class and not a instance than it is a proc-callback.
additional parameters

TCL also allows additional parameters to be passed to the callback, for example, to support a specific implementation. These parameters are added at the end of the callback-call.

Example: If the callback provide two arguments by default (arg1 and arg2), the following definition:

  • define-callback-command [list instance callback add1 add2 add3]

results in the following callback call:

  • instance callback arg1 arg2 add1 add2 add3
See also
Read more about how to define a service-callback in theLink .

MkKernel callback

Callback signature

  • MkObjectDeleteCallbackSetup
    callback-args := typeName:MK_STRN[in], typeHdl:MK_HDL[in], objHdl:MK_HDL[in]
    [static] proc callback { callback-args ?additional-args...? } ...
    MkObjectC DeleteCallbackSetup "NAME" callback "FILTER"
    [instance] ::oo::class create XXX {
    method callback { callback-args ?additional-args...? } ...
    }
    MkObjectC DeleteCallbackSetup "NAME" [list [self] callback] "FILTER"
    [class] ::oo::class create YYY {
    self method callback { callback-args ?additional-args...? } ...
    }
    MkObjectC DeleteCallbackSetup "NAME" [list YYY callback] "FILTER"

Callback example

RPC server

Example about the delete-callback-setup from the RPC server example/tcl/LibSq3LiteRpcServer.tcl

ServerSetup : The DeleteCallback is usually installed in the Setup-Callback but only once.

    if {[my ConfigGetIsParent]} {
      # call “ObjectDeleteCall” ONLY when deleting an instance whose class name matches the regular expression “^Sq3”
      MkObjectC DeleteCallbackSetup "LibSq3LiteRpcServer" [list [self] ObjectDeleteCall] "^Sq3"
    }

The DeleteCallback is called before the deletion. In the RPC example, the RPC client is informed about the impending deletion.

oo::define LibSq3LiteRpcServer method ObjectDeleteCall { typeName typeHdl objHdl } {
  my Send "E" "%DEL:CHH" $typeName $typeHdl $objHdl
}
oo::define LibSq3LiteRpcServer export ObjectDeleteCall

ServerCleanup : If the RPC server is deleted, the DeleteCallback is no longer needed and is therefore also deleted.

    if {[my ConfigGetIsParent]} {
      MkObjectC DeleteCallbackCleanup "LibSq3LiteRpcServer"
    }
RPC client

Example about the delete-callback-setup from the RPC client example/tcl/LibSq3LiteRpcClient.tcl

Constructor: Add the DeleteCallback-Service if not already available :

oo::define Sq3LiteRpc constructor { rpcHdl args} {
  next $rpcHdl {*}$args

  # only use "DeleteCallback" on the initial (Parent) context
  set parentRpc         [$rpcHdl LinkGetParent]

  # add service "%DEL" as static-callback "Sq3LiteDestructor"
  $parentRpc ServiceCreate "%DEL" [list Sq3LiteRpc Sq3LiteDestructor $rpcHdl]
}

DeleteCallback: If the objHdl is still available delete the obj :

oo::define Sq3LiteRpc self method Sq3LiteDestructor {parentRpc childRpc} {
  set typName [$parentRpc ReadSTR]
  set typHdl  [$parentRpc ReadHDL]
  set objHdl  [$parentRpc ReadHDL]

  # type=MyClassS -> rpc=MyClassRpc
  set classRpc  [string replace $typName end end Rpc]

  # hdl=objHdl -> obj
  set obj   [$childRpc CacheLookup $classRpc $objHdl]

  # is "obj" already deleted ?
  if {$obj eq "MK_NULL"} return

  # now delete "obj"
  try {
    # the "objHdl" is already deleted on server, avoid resent 
    $obj hdl 0
    $obj destroy
  } on error {} {
    [$parentRpc ErrorCatch] Println
  }
}
oo::define Sq3LiteRpc export Sq3LiteDestructor

LcConfig callback

Callback signature

  • LcConfigSetIncludeFunc
    callback-args := inclDir:String[in] path:String[in] ret:MkBufferListC[inout]
    [static] proc callback { callback-args ?additional-args...? } ...
    $cfg SetIncludeFunc callback
    [instance] ::oo::class create YYY {
    method callback { callback-args ?additional-args...? } ...
    }
    $cfg SetIncludeFunc [list [self] callback]
    [class] ::oo::class create YYY {
    self method callback { callback-args ?additional-args...? } ...
    }
    $cfg SetIncludeFunc [list YYY callback]
  • LcConfigSetSettingDeleteFunc
    callback-args := hdl:EXPORT-HANDLE[in]
    [static] proc callback { callback-args ?additional-args...? } ...
    $cfg SetSettingDeleteFunc callback
    [instance] ::oo::class create XXX {
    method callback { callback-args ?additional-args...? } ...
    }
    $cfg SetSettingDeleteFunc [list [self] callback]
    [class] ::oo::class create YYY {
    self method callback { callback-args ?additional-args...? } ...
    }
    $cfg SetSettingDeleteFunc [list YYY callback]

Callback example from RPC server

Callback setup
Example from LibLcConfigRpcServer.tcl using LcConfigSetIncludeFunc with callback
  oo::define LibLcConfigRpcServer method LcConfigSetIncludeFunc {} {
    set cfg [my LcConfigC_RpcRead]
    set fConfigIncludeData_ptr [my ReadSTR]
    $cfg SetIncludeFunc [list [self] $fConfigIncludeData_ptr]
    if {[my ServiceIsTransaction]} {
      my Send "R"
    }
  }
Callback definition
Example from LcConfigServer.tcl callback to be called
  # use "include_func" as "proc"
  method include_func { cfg dir match ret } {
    $ret AppendLA [MkBufferListC FileGlob [file join $dir $match]]
  }

Callback defined by tcllcconfig

Global LcConfigSetIncludeFunc_RT (MK_RT mkrt, LC_CFG const cfg, LcConfigIncludeCallF fConfigIncludeCall, LC_CBP fConfigIncludeData, LcConfigIncludeFreeF fConfigIncludeFree)
LcConfigSetIncludeFunc
Global LcConfigSetSettingDeleteFunc_RT (MK_RT mkrt, LC_CFG const cfg, LcSettingDeleteCallF fSettingDeleteCall, LC_CBP fSettingDeleteData, LcSettingDeleteFreeF fSettingDeleteFree)
LcConfigSetSettingDeleteFunc