cutelyst 4.3.0
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-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/context.h>
9#include <Cutelyst/cutelyst_global.h>
10#include <Cutelyst/request.h>
11#include <Cutelyst/response.h>
12
13#include <QObject>
14
15#define STR(X) #X
16#define C_PATH(X, Y) Q_CLASSINFO(STR(X##_Path), STR(Y))
17
23#define C_NAMESPACE(value) Q_CLASSINFO("Namespace", value)
24
41#define C_ATTR(X, Y) Q_CLASSINFO(STR(X), STR(Y)) Q_INVOKABLE
42
46#define CActionFor(str) \
47 ([this]() -> Cutelyst::Action * { \
48 static thread_local Cutelyst::Action *action = Cutelyst::Controller::actionFor(str); \
49 return action; \
50 }())
51
52namespace Cutelyst {
53
54class ControllerPrivate;
55class CUTELYST_LIBRARY Controller : public QObject
56{
57 Q_OBJECT
58public:
62 explicit Controller(QObject *parent = nullptr);
63 virtual ~Controller();
64
76 [[nodiscard]] QString ns() const noexcept;
77
84 Action *actionFor(QStringView name) const;
85
90 [[nodiscard]] ActionList actions() const noexcept;
91
95 bool operator==(const char *className);
96
97protected:
106 virtual bool preFork(Application *app);
107
116 virtual bool postFork(Application *app);
117
123 bool _DISPATCH(Context *c);
124
125 ControllerPrivate *d_ptr;
126
127private:
128 Q_DECLARE_PRIVATE(Controller)
129 friend class Application;
130 friend class Dispatcher;
131};
132
133} // namespace Cutelyst
This class represents a Cutelyst Action.
Definition action.h:36
The Cutelyst application.
Definition application.h:66
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.