cutelyst 4.0.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
26class CUTELYST_LIBRARY Dispatcher : public QObject
27{
28 Q_OBJECT
29public:
33 Dispatcher(QObject *parent = nullptr);
35
39 [[nodiscard]] Action *getAction(QStringView name, QStringView nameSpace = {}) const;
40
44 [[nodiscard]] Action *getActionByPath(QStringView path) const;
45
50 [[nodiscard]] ActionList getActions(QStringView name, QStringView nameSpace) const;
51
55 [[nodiscard]] Controller *controller(QStringView name) const;
56
60 [[nodiscard]] QList<Controller *> controllers() const;
61
70 [[nodiscard]] QString uriForAction(Action *action, const QStringList &captures) const;
71
77 [[nodiscard]] Action *expandAction(const Context *c, Action *action) const;
78
83 [[nodiscard]] QVector<DispatchType *> dispatchers() const;
84
85protected:
89 void setupActions(const QVector<Controller *> &controllers,
90 const QVector<DispatchType *> &dispatchers,
91 bool printActions);
92
97 bool dispatch(Context *c);
98
102 bool forward(Context *c, Component *component);
103
107 bool forward(Context *c, QStringView opname);
108
112 void prepareAction(Context *c);
113
114protected:
115 friend class Application;
116 friend class Context;
117 friend class Controller;
118 DispatcherPrivate *d_ptr;
119
120private:
121 Q_DECLARE_PRIVATE(Dispatcher)
122};
123
124} // namespace Cutelyst
This class represents a Cutelyst Action.
Definition: action.h:35
The Cutelyst Application.
Definition: application.h:43
The Cutelyst Component base class.
Definition: component.h:26
The Cutelyst Context.
Definition: context.h:38
Cutelyst Controller base class
Definition: controller.h:87
The Cutelyst Dispatcher.
Definition: dispatcher.h:27
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:8
QVector< Action * > ActionList
Definition: action.h:154