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

List of all callback defined by ccmqmsgque

The callback have to be a interface, instance-callback or class-callback.

There a two different types of callback:

  1. A callback used to define a context
  2. A callback used to define a service

Callback signature

The callback is implemented as:

type code example
interface ccmqmsgque::MqServiceIF Filter4
instance-callback ccmqmsgque::MqContextC::MqTokenICB manfilter
class-callback ccmqmsgque::MqContextC::MqTokenCCB Filter6

Using the signature:

class MqServiceIF {
public:
virtual void Service (MqContextC * const ctx) = 0;
};
typedef MqServiceIF MqServiceIF;
typedef void (MqContextC::*MqTokenICB) ();
typedef MqTokenICB MqBgErrorICB;
typedef MqTokenICB MqServiceICB;
typedef MqTokenICB MqServerSetupICB;
typedef MqTokenICB MqServerCleanupICB;
typedef MqTokenICB MqEventICB;
typedef void (*MqTokenCCB) (MqContextC*);
typedef MqTokenCCB MqBgErrorCCB;
typedef MqTokenCCB MqServiceCCB;
typedef MqTokenCCB MqServerSetupCCB;
typedef MqTokenCCB MqServerCleanupCCB;
typedef MqTokenCCB MqEventCCB;

Example from Callback.cc using MqServiceCreate with callback

#include "LibMqMsgque_cc.hh"

using namespace ccmkkernel;
using namespace ccmqmsgque;
using std::string;

// General rules for defining a callback in ATL
// --------------------------------------------
// 1.  The callback must be an \e instance of a class with the interface \WNS{MqServiceIF}
// 2.  The callback must be an \e static-method of a class with the interface \WNS{MqServiceCCB}
// 2.  The callback must be an \e instance-method of a class with the interface \WNS{MqServiceICB}

// attention, the "::OtherServerC" has no "::MqContextC" as "base-class" and require the "MqContextC::" prefix.
class OtherServerC : public MqServiceIF {
  private:
    string wht = "";
  public:
    OtherServerC(string _wht) {
      wht = _wht;
    }
    // The "otherInstanceService" require an extra argument, the "cbCtx".
    void Service (MqContextC *cbCtx) {
      cbCtx->Send("R", "C", (std::string(cbCtx->ReadSTR()) + "-" + wht + "-Other-Instance").c_str());
    }
    // The "otherClassService" require an extra argument, the "cbCtx".
    static void otherClassService (MqContextC *cbCtx) {
      cbCtx->Send("R", "C", (std::string(cbCtx->ReadSTR()) + "-World-Other-Class").c_str());
    }
};

// The "procService" require an extra argument, the "cbCtx".
void procService (MqContextC *cbCtx) {
  cbCtx->Send("R", "C", (std::string(cbCtx->ReadSTR()) + "-World-Proc").c_str());
}

class CallbackC : public MqContextC, public MqServerSetupIF {
  friend class MqFactoryCT<CallbackC>;

  private: 
  OtherServerC otherCtx{"World"};

  // factory startup (constructor)
  CallbackC (MK_TYP const typ, MqContextC* tmpl=NULL) : 
    MqContextC(typ,tmpl) { }

  // The "ownInstanceService" require no extra argument.
  void ownInstanceService () {
    Send("R", "C", (string(ReadSTR()) + "-World-Own-Instance").c_str());
  }

  // The "ownClassService" require an extra argument, the "cbCtx".
  static void ownClassService (MqContextC *cbCtx) {
    cbCtx->Send("R", "C", (string(cbCtx->ReadSTR()) + "-World-Own-Class").c_str());
  }

  // the "serverSetup" defines the test-services
  void ServerSetup () {
    // 1. The "otherInstanceCallback" require an extra argument, the "otherCtx".
      ServiceCreate("HLW1",&otherCtx);

    // 2. The "otherClassCallback" require no extra argument.
      // -> remember: use the *absolute-namespace* for the callback
      ServiceCreate("HLW2",OtherServerC::otherClassService);

    // 3. The "ownInstanceCallback" require no extra argument.
      ServiceCreate("HLW3",MqServiceICB(&CallbackC::ownInstanceService));

    // 4. The "otherClassCallback" require no extra argument.
      ServiceCreate("HLW4",ownClassService);

    // 5. The "procCallback" require NO extra argument
      ServiceCreate("HLW5",procService);
  }
};

// package-main
int MK_CDECL main(int argc, MK_STRN argv[]) {
  MqMsgque::CcMqSetup();

  // setup commandline arguments for later use
  MkBufferListC largs = {argc, argv};
  // create "CallbackC" factory… and make it to the default.
  MqFactoryCT<CallbackC>::Add("CallbackC")->Default();

  // inspect commandline-argument for the "factory" to choose… and create a object
  auto srv = MqFactoryCT<MqContextC>::GetCalled(largs)->New();
  // start listen for incoming call's
  try {
    srv->LinkCreate(largs);
    srv->ProcessEvent (MQ_WAIT_FOREVER);
  } catch (const std::exception& e) {
    srv->ErrorCatch(e);
  }
  return srv->Exit();
}

Callbacks defined by ccmqmsgque

Member libmqmsgque::MqSendEND_AND_CALLBACK_RT (MK_RT mkrt, MQ_CTX const ctx, MQ_TOK const token, MqServiceCallbackF const fCall, MK_CBP callback, MqDataFreeF fFree, MK_TIME_T const timeout)
MqSendEND_AND_CALLBACK
Member libmqmsgque::MqSendEND_AND_SUB_RT (MK_RT mkrt, MQ_CTX const ctx, MQ_TOK const token, MqServiceCallbackF const fCall, MK_CBP callback, MqDataFreeF fFree, MK_TIME_T timeout)
MqSendEND_AND_SUB
Member libmqmsgque::MqServiceCreate_RT (MK_RT mkrt, MQ_CTX const ctx, MQ_TOK const token, MqServiceCallbackF const fCall, MK_CBP callback, MqDataFreeF fFree, MkMarkF fMark)
MqServiceCreate
Member libmqmsgque::MqSetupS::BgError
ConfigApi_MqBgErrorIF
Member libmqmsgque::MqSetupS::Event
ConfigApi_MqEventIF
Member libmqmsgque::MqSetupS::ServerCleanup
ConfigApi_MqServerCleanupIF
Member libmqmsgque::MqSetupS::ServerSetup
ConfigApi_MqServerSetupIF