cutelyst 3.9.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
action.h
1/*
2 * SPDX-FileCopyrightText: (C) 2013-2022 Daniel Nicoletti <dantti12@gmail.com>
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5#ifndef CUTELYST_ACTION_H
6#define CUTELYST_ACTION_H
7
8#include <Cutelyst/component.h>
9#include <Cutelyst/context.h>
10#include <Cutelyst/cutelyst_global.h>
11
12#include <QtCore/QMetaMethod>
13#include <QtCore/QStringList>
14
15namespace Cutelyst {
16
17class Controller;
18class Dispatcher;
19class ActionPrivate;
34class CUTELYST_LIBRARY Action : public Component
35{
37public:
41 explicit Action(QObject *parent = nullptr);
42 virtual ~Action() override = default;
43
44 virtual Modifiers modifiers() const override;
45
51 ParamsMultiMap attributes() const noexcept;
52
60 QString attribute(const QString &name, const QString &defaultValue = {}) const;
61
67
71 QString className() const;
72
76 Controller *controller() const;
77
81 inline bool dispatch(Context *c) { return c->execute(this); }
82
87 virtual bool match(int numberOfArgs) const noexcept;
88
99 virtual bool matchCaptures(int numberOfCaptures) const noexcept;
100
104 QString ns() const noexcept;
105
111 virtual qint8 numberOfArgs() const noexcept;
112
117 virtual qint8 numberOfCaptures() const noexcept;
118
119protected:
120 friend class Dispatcher;
121 friend class ControllerPrivate;
122
127 explicit Action(ActionPrivate *ptr, QObject *parent = nullptr);
128
132 virtual bool doExecute(Context *c) override;
133
137 void setMethod(const QMetaMethod &method);
138
142 void setController(Controller *controller);
143
147 void setupAction(const QVariantHash &args, Application *app);
148
149private:
150 Q_DECLARE_PRIVATE(Action)
151};
152
155
156} // namespace Cutelyst
157
158#endif // CUTELYST_ACTION_H
This class represents a Cutelyst Action.
Definition action.h:35
void setAttributes(const ParamsMultiMap &attributes)
Definition action.cpp:80
bool dispatch(Context *c)
Definition action.h:81
QString className() const
Definition action.cpp:86
Action(QObject *parent=nullptr)
Definition action.cpp:12
virtual Modifiers modifiers() const override
Definition action.cpp:22
ParamsMultiMap attributes() const noexcept
Definition action.cpp:68
Controller * controller() const
Definition action.cpp:92
QString attribute(const QString &name, const QString &defaultValue={}) const
Definition action.cpp:74
The Cutelyst Application.
Definition application.h:43
Component(QObject *parent=nullptr)
Definition component.cpp:11
QString name() const
Definition component.cpp:33
The Cutelyst Context.
Definition context.h:39
bool execute(Component *code)
Definition context.cpp:429
Cutelyst Controller base class
Definition controller.h:88
The Cutelyst Dispatcher.
Definition dispatcher.h:28
The Cutelyst namespace holds all public Cutelyst API.
Definition Mainpage.dox:8
QMultiMap< QString, QString > ParamsMultiMap
QVector< Action * > ActionList
Definition action.h:154
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
QObject * parent() const const