cutelyst 3.9.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
controller.h
1/*
2 * SPDX-FileCopyrightText: (C) 2013-2022 Daniel Nicoletti <dantti12@gmail.com>
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5#ifndef CUTELYST_CONTROLLER_H
6#define CUTELYST_CONTROLLER_H
7
8#include <Cutelyst/action.h>
9#include <Cutelyst/context.h>
10#include <Cutelyst/cutelyst_global.h>
11#include <Cutelyst/request.h>
12#include <Cutelyst/response.h>
13
14#include <QObject>
15
16#define STR(X) #X
17#define C_PATH(X, Y) Q_CLASSINFO(STR(X##_Path), STR(Y))
18#define C_NAMESPACE(value) Q_CLASSINFO("Namespace", value)
19#define C_ATTR(X, Y) Q_CLASSINFO(STR(X), STR(Y)) Q_INVOKABLE
20
21#define CActionFor(str) \
22 ([this]() -> Cutelyst::Action * { \
23 static thread_local Cutelyst::Action *action = Cutelyst::Controller::actionFor(str); \
24 return action; \
25 }()) /**/
26
27namespace Cutelyst {
28
29class ControllerPrivate;
87class CUTELYST_LIBRARY Controller : public QObject
88{
90public:
94 explicit Controller(QObject *parent = nullptr);
95 virtual ~Controller();
96
106 QString ns() const;
107
114 Action *actionFor(const QString &name) const;
115
122 Action *actionFor(QStringView name) const;
123
128 ActionList actions() const;
129
133 bool operator==(const char *className);
134
135protected:
144 virtual bool preFork(Application *app);
145
154 virtual bool postFork(Application *app);
155
161 bool _DISPATCH(Context *c);
162
163 ControllerPrivate *d_ptr;
164
165private:
166 Q_DECLARE_PRIVATE(Controller)
167 friend class Application;
168 friend class Dispatcher;
169};
170
171} // namespace Cutelyst
172
173#endif // CUTELYST_CONTROLLER_H
This class represents a Cutelyst Action.
Definition action.h:35
The Cutelyst Context.
Definition context.h:39
virtual bool preFork(Application *app)
Action * actionFor(const QString &name) const
ActionList actions() const
virtual bool postFork(Application *app)
bool operator==(const char *className)
QString ns() const
bool _DISPATCH(Context *c)
Controller(QObject *parent=nullptr)
The Cutelyst namespace holds all public Cutelyst API.
Definition Mainpage.dox:8
QVector< Action * > ActionList
Definition action.h:154
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
QObject * parent() const const