theKernel 10.0 NHI1 - theKernel - theLink - theConfig - theSq3Lite - theCompiler - theBrain - theGuard
c - tcl - cs - py - rb - jv - cc
Loading...
Searching...
No Matches
Callback Signature List

List of all callback defined by ccmkkernel

The callback have to be a C++ proc or method

Callback signature

typedef void (MkObjectC::*ccmkkernel::MkObjectC::MkObjectDeleteICB) (MkObjectC *);
typedef void (*ccmkkernel::MkObjectC::MkObjectDeleteCCB) (MkObjectC*,MkObjectC*);
typedef void (*ccmkkernel::MkObjectDeleteSCB) (MkObjectC*);
void(*) MkObjectDeleteCCB(MkObjectC *, MK_STRN const, MK_HDL const, MK_HDL const)
class-callback
void(MkObjectC::*) MkObjectDeleteICB(MK_STRN const, MK_HDL const, MK_HDL const)
instance-callback
void(* MkObjectDeleteSCB)(MK_STRN const, MK_HDL const, MK_HDL const)
static-callback
Note
For the C-language the fCall is the function called and the callback is the additional data. This is different for the non-C-languges from (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO).
For the non-C-language the fCall is internal and the callback is the target-language-callback as data attribute.

Read more about how to define a service-callback in theLink .

Callback example

RPC server

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

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

      if (ConfigGetIsParent()) {
        // call “ObjectDeleteCall” ONLY when deleting an instance whose class name matches the regular expression “^Sq3”
        MkObjectC::DeleteCallbackSetup("LibSq3LiteRpcServer",
            MkObjectDeleteICB(&LibSq3LiteRpcServer::ObjectDeleteCall),"^Sq3");
      }

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

void LibSq3LiteRpcServer::ObjectDeleteCall ( MK_STRN const typeName, MK_HDL const typeHdl, MK_HDL const objHdl ) {
  Send("E","%DEL:CHH",typeName,typeHdl,objHdl);
}

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

      if (ConfigGetIsParent()) {
        MkObjectC::DeleteCallbackSetup("LibSq3LiteRpcServer",
            MkObjectDeleteICB(&LibSq3LiteRpcServer::ObjectDeleteCall),"^Sq3");
      }

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
Member libmkkernel::MkObjectDeleteCallbackSetup_RT (MK_RT mkrt, MK_STRN ident, MkObjectDeleteCallF fCall, MK_CBP callback, MkObjectDeleteFreeF fFree, MK_STRN filter)
MkObjectDeleteCallbackSetup