AusweisApp2
Lade ...
Suche ...
Keine Treffer
WorkflowRequest.h
gehe zur Dokumentation dieser Datei
1
5#pragma once
6
8
9#include <QPair>
10
11#include <functional>
12#include <utility>
13
14namespace governikus
15{
16defineEnumType(WorkflowControl
17 , UNHANDLED
18 , SKIP
19 , ENQUEUE
20 )
21
23
24class WorkflowRequest final
25{
26 Q_GADGET
27
28 using BusyHandler = std::function<WorkflowControl (WorkflowRequest&, const QSharedPointer<WorkflowRequest>&, const QSharedPointer<WorkflowRequest>&)>;
29
30 private:
31 const std::function<QSharedPointer<WorkflowController>(const QSharedPointer<WorkflowContext>& pContext)> mGeneratorController;
32 const std::function<QSharedPointer<WorkflowContext>()> mGeneratorContext;
33 const BusyHandler mBusyHandler;
34
35 QSharedPointer<WorkflowController> mController;
36 QSharedPointer<WorkflowContext> mContext;
37
38 template<typename Controller, typename Context, typename ... Args>
39 static auto getGenerator(Args&& ... pArgs)
40 {
41 const auto& controller = [](const QSharedPointer<WorkflowContext>& pContext){
42 return QSharedPointer<Controller>::create(pContext.staticCast<Context>());
43 };
44
45 const auto& context = [pArgs ...]() mutable {
46 return QSharedPointer<Context>::create(std::forward<Args>(pArgs) ...);
47 };
48
49 return qMakePair(controller, context);
50 }
51
52 public:
53 template<typename Controller, typename Context, typename Request = WorkflowRequest, typename ... Args>
54 static QSharedPointer<WorkflowRequest> createWorkflowRequest(Args&& ... pArgs)
55 {
56 auto [controller, context] = getGenerator<Controller, Context, Args...>(std::forward<Args>(pArgs) ...);
57 return QSharedPointer<Request>::create(controller, context);
58 }
59
60
61 template<typename Controller, typename Context, typename Request = WorkflowRequest, typename ... Args>
62 static QSharedPointer<WorkflowRequest> createWorkflowRequestHandler(const BusyHandler& pBusyHandler, Args&& ... pArgs)
63 {
64 auto [controller, context] = getGenerator<Controller, Context, Args...>(std::forward<Args>(pArgs) ...);
65 return QSharedPointer<Request>::create(controller, context, pBusyHandler);
66 }
67
68
69 WorkflowRequest(const std::function<QSharedPointer<WorkflowController>(const QSharedPointer<WorkflowContext>& pContext)>& pGeneratorController,
70 const std::function<QSharedPointer<WorkflowContext>()>& pGeneratorContext,
71 const BusyHandler& pBusyHandler = BusyHandler());
72
73 void initialize();
74 [[nodiscard]] bool isInitialized() const;
75 [[nodiscard]] Action getAction() const;
76 [[nodiscard]] QSharedPointer<WorkflowController> getController() const;
77 [[nodiscard]] QSharedPointer<WorkflowContext> getContext() const;
78 [[nodiscard]] WorkflowControl handleBusyWorkflow(const QSharedPointer<WorkflowRequest>& pActiveWorkflow, const QSharedPointer<WorkflowRequest>& pWaitingWorkflow);
79};
80
81} // namespace governikus
#define defineEnumType(enumName,...)
Definition EnumHelper.h:98
Definition WorkflowController.h:22
Definition WorkflowRequest.h:25
Action getAction() const
Definition WorkflowRequest.cpp:41
static QSharedPointer< WorkflowRequest > createWorkflowRequestHandler(const BusyHandler &pBusyHandler, Args &&... pArgs)
Definition WorkflowRequest.h:62
void initialize()
Definition WorkflowRequest.cpp:26
QSharedPointer< WorkflowContext > getContext() const
Definition WorkflowRequest.cpp:53
QSharedPointer< WorkflowController > getController() const
Definition WorkflowRequest.cpp:47
WorkflowControl handleBusyWorkflow(const QSharedPointer< WorkflowRequest > &pActiveWorkflow, const QSharedPointer< WorkflowRequest > &pWaitingWorkflow)
Definition WorkflowRequest.cpp:59
bool isInitialized() const
Definition WorkflowRequest.cpp:35
WorkflowRequest(const std::function< QSharedPointer< WorkflowController >(const QSharedPointer< WorkflowContext > &pContext)> &pGeneratorController, const std::function< QSharedPointer< WorkflowContext >()> &pGeneratorContext, const BusyHandler &pBusyHandler=BusyHandler())
static QSharedPointer< WorkflowRequest > createWorkflowRequest(Args &&... pArgs)
Definition WorkflowRequest.h:54
Implementation of GeneralAuthenticate response APDUs.
Definition CommandApdu.h:16