cutelyst  3.7.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-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 <QtCore/qobject.h>
9 #include <QtCore/qhash.h>
10 #include <QtCore/qstringlist.h>
11 
12 #include <Cutelyst/action.h>
13 #include <Cutelyst/cutelyst_global.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 
72  Action *expandAction(const Context *c, Action *action) const;
73 
78  QVector<DispatchType *> dispatchers() const;
79 
80 protected:
84  void setupActions(const QVector<Controller *> &controllers, const QVector<DispatchType *> &dispatchers, bool printActions);
85 
90  bool dispatch(Context *c);
91 
95  bool forward(Context *c, Component *component);
96 
100  bool forward(Context *c, const QString &opname);
101 
105  void prepareAction(Context *c);
106 
107 protected:
108  friend class Application;
109  friend class Context;
110  friend class Controller;
111  DispatcherPrivate *d_ptr;
112 
113 private:
114  Q_DECLARE_PRIVATE(Dispatcher)
115 };
116 
117 }
118 
119 #endif // CUTELYST_DISPATCHER_H
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:39
Cutelyst Controller base class
Definition: controller.h:90
The Cutelyst Dispatcher.
Definition: dispatcher.h:28
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:8
QVector< Action * > ActionList
Definition: action.h:153