cutelyst  3.9.1
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-2022 Daniel Nicoletti <dantti12@gmail.com>
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 #ifndef CUTELYST_DISPATCHER_H
6 #define CUTELYST_DISPATCHER_H
7 
8 #include <Cutelyst/action.h>
9 #include <Cutelyst/cutelyst_global.h>
10 
11 #include <QtCore/qhash.h>
12 #include <QtCore/qobject.h>
13 #include <QtCore/qstringlist.h>
14 
15 namespace Cutelyst {
16 
17 class Context;
18 class Controller;
19 class DispatchType;
20 class DispatcherPrivate;
21 
27 class CUTELYST_LIBRARY Dispatcher : public QObject
28 {
29  Q_OBJECT
30 public:
34  Dispatcher(QObject *parent = nullptr);
35  ~Dispatcher();
36 
40  Action *getAction(const QString &name, const QString &nameSpace = QString()) const;
41 
45  Action *getActionByPath(const QString &path) const;
46 
51  ActionList getActions(const QString &name, const QString &nameSpace) const;
52 
56  QMap<QString, Controller *> controllers() const;
57 
66  QString uriForAction(Action *action, const QStringList &captures) const;
67 
73  Action *expandAction(const Context *c, Action *action) const;
74 
79  QVector<DispatchType *> dispatchers() const;
80 
81 protected:
85  void setupActions(const QVector<Controller *> &controllers,
86  const QVector<DispatchType *> &dispatchers,
87  bool printActions);
88 
93  bool dispatch(Context *c);
94 
98  bool forward(Context *c, Component *component);
99 
103  bool forward(Context *c, const QString &opname);
104 
108  void prepareAction(Context *c);
109 
110 protected:
111  friend class Application;
112  friend class Context;
113  friend class Controller;
114  DispatcherPrivate *d_ptr;
115 
116 private:
117  Q_DECLARE_PRIVATE(Dispatcher)
118 };
119 
120 } // namespace Cutelyst
121 
122 #endif // CUTELYST_DISPATCHER_H
The Cutelyst Component base class.
Definition: component.h:25
This class represents a Cutelyst Action.
Definition: action.h:34
The Cutelyst Context.
Definition: context.h:38
Cutelyst Controller base class
Definition: controller.h:87
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7
The Cutelyst Application.
Definition: application.h:42
The Cutelyst Dispatcher.
Definition: dispatcher.h:27