theLink 10.0
Loading...
Searching...
No Matches
MqFactoryC_Misc_C_API

MqFactoryC - various functions to work on a factoryMore...

+ Collaboration diagram for MqFactoryC_Misc_C_API:

Functions

MQ_FCT libmqmsgque::MqFactoryDefault_RT (MK_RT mkrt, MQ_FCT const fct)
 set the default-attribute to the factory
 
MQ_FCT libmqmsgque::MqFactoryInitial_RT (MK_RT mkrt, MQ_FCT const fct)
 set the initial-attribut to fct
 
MK_STRN libmqmsgque::MqFactoryDefaultIdent_RT (MK_RT mkrt)
 return the factory-identifier of the default MqFactoryC
 
MK_STRN libmqmsgque::MqFactoryInitialIdent_RT (MK_RT mkrt)
 return the factory-identifier of the initial MqFactoryC
 
enum MkErrorE libmqmsgque::MqFactoryNew_RT (MK_RT mkrt, MQ_FCT const fct, MQ_CTX const tmpl, MQ_CTX *const val_out)
 create a new MqContextC from a MqFactoryC
 
void libmqmsgque::MqFactoryLogAll_RT (MK_RT mkrt, MK_STRN const callfunc)
 log all "factories" to stderr
 

MqFactoryLog

void libmqmsgque::MqFactoryLog_RT (MK_RT mkrt, MQ_FCTN const fct, MK_OBJN fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_I32 const lvl)
 log the MqFactoryC
 
#define MqFactoryLog_2M(fct, m)
 

MqFactoryC - MqFactoryC_Misc_C_API - overload

#define MqFactoryDefault_NULL(...)
 
#define MqFactoryDefault(...)
 
#define MqFactoryInitial_NULL(...)
 
#define MqFactoryInitial(...)
 
#define MqFactoryNew_NULL(...)
 
#define MqFactoryNew(...)
 
#define MqFactoryNew_2(fct, val_out)
 
#define MqFactoryNew_E(...)
 
#define MqFactoryNew_C(...)
 
#define MqFactoryNew_e(...)
 
#define MqFactoryLog_NULL(...)
 
#define MqFactoryLog(...)
 
#define MqFactoryLog_4(fct, fmtobj, debug, callfunc)
 
#define MqFactoryLog_3(fct, fmtobj, debug)
 
#define MqFactoryLog_2(fct, fmtobj)
 
#define MqFactoryLog_1(fct)
 
#define MqFactoryDefaultIdent_NULL()
 
#define MqFactoryDefaultIdent()
 
#define MqFactoryInitialIdent_NULL()
 
#define MqFactoryInitialIdent()
 
#define MqFactoryLogAll_NULL(...)
 
#define MqFactoryLogAll(...)
 
#define MqFactoryLogAll_0()
 

Detailed Description

MqFactoryC - various functions to work on a factory

Macro Definition Documentation

◆ MqFactoryDefault

#define MqFactoryDefault ( ...)
Value:
MqFactoryDefault_RT(MK_RT_CALL __VA_ARGS__)
#define MK_RT_CALL

Definition at line 1012 of file msgque_overload_mq.h.

◆ MqFactoryDefault_NULL

#define MqFactoryDefault_NULL ( ...)
Value:
MqFactoryDefault_RT(MK_RT_CALL_NULL __VA_ARGS__)
#define MK_RT_CALL_NULL

Definition at line 1011 of file msgque_overload_mq.h.

◆ MqFactoryDefaultIdent

#define MqFactoryDefaultIdent ( )
Value:
MqFactoryDefaultIdent_RT(MK_RT_CALL_ONLY)
#define MK_RT_CALL_ONLY

Definition at line 1034 of file msgque_overload_mq.h.

◆ MqFactoryDefaultIdent_NULL

#define MqFactoryDefaultIdent_NULL ( )
Value:
MqFactoryDefaultIdent_RT(MK_RT_CALL_NULL_ONLY)
#define MK_RT_CALL_NULL_ONLY

Definition at line 1033 of file msgque_overload_mq.h.

◆ MqFactoryInitial

#define MqFactoryInitial ( ...)
Value:
MqFactoryInitial_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 1014 of file msgque_overload_mq.h.

◆ MqFactoryInitial_NULL

#define MqFactoryInitial_NULL ( ...)
Value:
MqFactoryInitial_RT(MK_RT_CALL_NULL __VA_ARGS__)

Definition at line 1013 of file msgque_overload_mq.h.

◆ MqFactoryInitialIdent

#define MqFactoryInitialIdent ( )
Value:
MqFactoryInitialIdent_RT(MK_RT_CALL_ONLY)

Definition at line 1036 of file msgque_overload_mq.h.

◆ MqFactoryInitialIdent_NULL

#define MqFactoryInitialIdent_NULL ( )
Value:
MqFactoryInitialIdent_RT(MK_RT_CALL_NULL_ONLY)

Definition at line 1035 of file msgque_overload_mq.h.

◆ MqFactoryLog

#define MqFactoryLog ( ...)
Value:
MqFactoryLog_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 1026 of file msgque_overload_mq.h.

◆ MqFactoryLog_1

#define MqFactoryLog_1 ( fct)
Value:
MqFactoryLog(fct,NULL,0,__func__,0)
#define MqFactoryLog(...)

Definition at line 1030 of file msgque_overload_mq.h.

◆ MqFactoryLog_2

#define MqFactoryLog_2 ( fct,
fmtobj )
Value:
MqFactoryLog(fct,fmtobj,0,__func__,0)

Definition at line 1029 of file msgque_overload_mq.h.

◆ MqFactoryLog_2M

#define MqFactoryLog_2M ( fct,
m )
Value:
MqFactoryLog(fct,MkObj(m),0,__func__,0)

Definition at line 3746 of file LibMqMsgque_mq.h.

◆ MqFactoryLog_3

#define MqFactoryLog_3 ( fct,
fmtobj,
debug )
Value:
MqFactoryLog(fct,fmtobj,debug,__func__,0)

Definition at line 1028 of file msgque_overload_mq.h.

◆ MqFactoryLog_4

#define MqFactoryLog_4 ( fct,
fmtobj,
debug,
callfunc )
Value:
MqFactoryLog(fct,fmtobj,debug,callfunc,0)

Definition at line 1027 of file msgque_overload_mq.h.

◆ MqFactoryLog_NULL

#define MqFactoryLog_NULL ( ...)
Value:
MqFactoryLog_RT(MK_RT_CALL_NULL __VA_ARGS__)

Definition at line 1025 of file msgque_overload_mq.h.

◆ MqFactoryLogAll

#define MqFactoryLogAll ( ...)
Value:
MqFactoryLogAll_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 1038 of file msgque_overload_mq.h.

◆ MqFactoryLogAll_0

#define MqFactoryLogAll_0 ( )
Value:
MqFactoryLogAll(__func__)
#define MqFactoryLogAll(...)

Definition at line 1039 of file msgque_overload_mq.h.

◆ MqFactoryLogAll_NULL

#define MqFactoryLogAll_NULL ( ...)
Value:
MqFactoryLogAll_RT(MK_RT_CALL_NULL __VA_ARGS__)

Definition at line 1037 of file msgque_overload_mq.h.

◆ MqFactoryNew

#define MqFactoryNew ( ...)
Value:
MqFactoryNew_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 1018 of file msgque_overload_mq.h.

◆ MqFactoryNew_2

#define MqFactoryNew_2 ( fct,
val_out )
Value:
MqFactoryNew(fct,NULL,val_out)
#define MqFactoryNew(...)

Definition at line 1019 of file msgque_overload_mq.h.

◆ MqFactoryNew_C

#define MqFactoryNew_C ( ...)
Value:
if (MkErrorCheckI(MqFactoryNew(__VA_ARGS__)))

Definition at line 1021 of file msgque_overload_mq.h.

◆ MqFactoryNew_E

#define MqFactoryNew_E ( ...)
Value:
MkErrorCheck(MqFactoryNew(__VA_ARGS__))

Definition at line 1020 of file msgque_overload_mq.h.

◆ MqFactoryNew_e

#define MqFactoryNew_e ( ...)
Value:
MK_EMBEDDED(MQ_CTX,MqFactoryNew,__VA_ARGS__)

Definition at line 1022 of file msgque_overload_mq.h.

◆ MqFactoryNew_NULL

#define MqFactoryNew_NULL ( ...)
Value:
MqFactoryNew_RT(MK_RT_CALL_NULL __VA_ARGS__)

Definition at line 1017 of file msgque_overload_mq.h.

Function Documentation

◆ MqFactoryDefault_RT()

MQ_FCT libmqmsgque::MqFactoryDefault_RT ( MK_RT mkrt,
MQ_FCT const fct )

set the default-attribute to the factory

The default-factory is used to create an MqFactoryC if MqFactoryGetCalled was not able to find a specific factory object. This is designed for a scenario with multiple factories included into a single binary and the first commandline parameter after the executable name… (position 0=executable, position 1=factory-selector)… is not related to a factory-ident… added with MqFactoryAdd.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]fctthe new default MqFactoryC
Returns
the input fct

Example: from example//server.cs

static void Main(string[] argv) {
var largv = new MkBufferListC(argv);
MqFactoryCT<Server>.Add("server").Default();
MqFactoryCT<Client>.Add("client");
// "ctx" get the "Default" factory "server" ... or ... the factory "client" ...
// if string "client" is on the FIRST position in "argv"
MqContextC ctx = MqFactoryCT<MqContextC>.GetCalled(largv).New();
try {
ctx.LinkCreate(largv);
ctx.LogC("this is the log test\n",1,"test");
ctx.ProcessEvent(MqWaitOnEventE.FOREVER);
} catch (Exception ex) {
ctx.ErrorCatch (ex);
} finally {
ctx.Exit();
}
}

◆ MqFactoryDefaultIdent_RT()

MK_STRN libmqmsgque::MqFactoryDefaultIdent_RT ( MK_RT mkrt)

return the factory-identifier of the default MqFactoryC

◆ MqFactoryInitial_RT()

MQ_FCT libmqmsgque::MqFactoryInitial_RT ( MK_RT mkrt,
MQ_FCT const fct )

set the initial-attribut to fct

The factory with "Initial"-attribute is always used for an object that should only be created with the MqContextC base class, but for which no other factory has been specified.
Use this attribute with care because you are firmly linking a factory. In a programming language with class-support, such as C++ or C#, this class is used for every new MqContextC object.
Where "Reflection" is available, this attribute has less meaning since the class is primarily determined from the parent object by means of "Reflection".
The "Initial" attribute is otherwise used for the "Loopback" and the "Filter" capability.

Example from Filter4.cc set Initial attribute to a Factory

int MK_CDECL main (int argc, MK_STRN argv[])
{
  MqMsgque::CcMqSetup();
  MqFactoryCT<Filter4>::Add("Filter4")->Initial();

  Filter4 filter;
  try {
    filter.Init();
    filter.LinkCreate (MkBufferListC {argc, argv});
    filter.ProcessEvent (MQ_WAIT_FOREVER);
  } catch (const exception& e) {
    filter.ErrorCatch(e);
  }
  return filter.Exit();
}
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]fctthe new initial MqFactoryC
Returns
the input fct

◆ MqFactoryInitialIdent_RT()

MK_STRN libmqmsgque::MqFactoryInitialIdent_RT ( MK_RT mkrt)

return the factory-identifier of the initial MqFactoryC

◆ MqFactoryLog_RT()

void libmqmsgque::MqFactoryLog_RT ( MK_RT mkrt,
MQ_FCTN const fct,
MK_OBJN fmtobj,
MK_DBG const debug,
MK_STRN const callfunc,
MK_I32 const lvl )

log the MqFactoryC

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]fctthe MqFactoryS instance to work on
[in]fmtobjmanaged object used to format the log-message (default=MK_NULL → use default-format)
[in]debugthe debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0)
[in]callfunca user-defined postfix to identify the calling-function or the environment (default = name-of-function, MK_NULL = resolve-own-name)
[in]lvla user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0)
See also
MqFactoryC

◆ MqFactoryLogAll_RT()

void libmqmsgque::MqFactoryLogAll_RT ( MK_RT mkrt,
MK_STRN const callfunc )

log all "factories" to stderr

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]callfunca user-defined postfix to identify the calling-function or the environment (default = name-of-function, MK_NULL = resolve-own-name)

◆ MqFactoryNew_RT()

enum MkErrorE libmqmsgque::MqFactoryNew_RT ( MK_RT mkrt,
MQ_FCT const fct,
MQ_CTX const tmpl,
MQ_CTX *const val_out )

create a new MqContextC from a MqFactoryC

this create only the initial-server-object… all other server-objects will be created on behalf of the client-request.

Example from MyServer.cc create a new server context

#include "LibMqMsgque_cc.hh"

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.
  MqFactoryCT<MyServer>::Add("MyServer")->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();
}
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]fcta MqFactoryC used to create a MqContextC
[in]tmpl(C-API only) template for context intialization
[out]val_outthe new context object as return or MK_NULL on error
Returns
the new MqContextC or NULL on error
Attention
(C-API only)
the programmer have-to check the return value on MK_NULL pointer
(non C-API only)
this is no hard constructor because the factory create the object and the self pointer is already available. ObjNew is used to extract the self pointer from the object