theLink 10.0
Loading...
Searching...
No Matches
Internal - ccmqmsgque::MqFactoryC* Add

The constructor have to be a C++ [class] with superclass [MqContextC]

+ Collaboration diagram for Internal - ccmqmsgque::MqFactoryC* Add:

The constructor have to be a C++ [class] with superclass [MqContextC]

  1. The factory is implemented as a template with ccmqmsgque::MqFactoryCT<class>.
  2. The class have to be a sub-class of ccmqmsgque::MqContextC.
  3. The class have to provide a factory-constructor like Filter6::Filter6.
  4. The factory-constructor is required in the ccmqmsgque::MqFactoryCT::ObjectSelfCreate new function.
example: use class MyServer with public name "MyServer" as a factory-class
using namespace ccmkkernel;
using namespace ccmqmsgque;
// package-item
class MyServer : public MqContextC, public MqServerSetupIF {
friend class MqFactoryCT<MyServer>;
private:
// define the factory constructor
MyServer(MK_TYP const typ, MqContextC* tmpl=NULL) : MqContextC(typ,tmpl) {};
private:
// service to serve all incoming requests for token "HLWO"
void MyFirstService () {
SendSTART();
SendV("%s World", ReadSTR());
SendRETURN();
}
// define a service as link between the token "HLWO" and the callback "MyFirstService"
void ServerSetup() {
ServiceCreate("HLWO", MqServiceICB(&MyServer::MyFirstService));
}
};
// package-main
int MK_CDECL main(int argc, MK_STRN argv[]) {
MqMsgque::CcMqSetup();
// setup commandline arguments for later use
MkBufferListC largs = {argc, argv};
// create "MyServer" factory… and make it to the default.
// inspect commandline-argument for the "factory" to choose… and create a object
// 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();
}