cutelyst 4.3.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
dispatcher.h
1/*
2 * SPDX-FileCopyrightText: (C) 2013-2023 Daniel Nicoletti <dantti12@gmail.com>
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5#pragma once
6
7#include <Cutelyst/action.h>
8#include <Cutelyst/cutelyst_global.h>
9
10#include <QtCore/qhash.h>
11#include <QtCore/qobject.h>
12#include <QtCore/qstringlist.h>
13
14namespace Cutelyst {
15
16class Context;
17class Controller;
18class DispatchType;
19class DispatcherPrivate;
20
28class CUTELYST_LIBRARY Dispatcher : public QObject
29{
30 Q_OBJECT
31public:
35 Dispatcher(QObject *parent = nullptr);
36
41
45 [[nodiscard]] Action *getAction(QStringView name, QStringView nameSpace = {}) const;
46
50 [[nodiscard]] Action *getActionByPath(QStringView path) const;
51
56 [[nodiscard]] ActionList getActions(QStringView name, QStringView nameSpace) const;
57
61 [[nodiscard]] Controller *controller(QStringView name) const;
62
66 [[nodiscard]] QList<Controller *> controllers() const;
67
76 [[nodiscard]] QString uriForAction(Action *action, const QStringList &captures) const;
77
83 [[nodiscard]] Action *expandAction(const Context *c, Action *action) const;
84
89 [[nodiscard]] QVector<DispatchType *> dispatchers() const;
90
91protected:
95 void setupActions(const QVector<Controller *> &controllers,
96 const QVector<DispatchType *> &dispatchers,
97 bool printActions);
98
103 bool dispatch(Context *c);
104
108 bool forward(Context *c, Component *component);
109
113 bool forward(Context *c, QStringView opname);
114
118 void prepareAction(Context *c);
119
120protected:
121 friend class Application;
122 friend class Context;
123 friend class Controller;
124 DispatcherPrivate *d_ptr;
125
126private:
127 Q_DECLARE_PRIVATE(Dispatcher)
128};
129
130} // namespace Cutelyst
This class represents a Cutelyst Action.
Definition action.h:36
The Cutelyst application.
Definition application.h:66
The Cutelyst Component base class.
Definition component.h:30
The Cutelyst Context.
Definition context.h:42
Cutelyst Controller base class.
Definition controller.h:56
The Cutelyst Dispatcher.
Definition dispatcher.h:29
The Cutelyst namespace holds all public Cutelyst API.