cutelyst 3.9.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
component.h
1/*
2 * SPDX-FileCopyrightText: (C) 2014-2022 Daniel Nicoletti <dantti12@gmail.com>
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5#ifndef CUTELYST_COMPONENT_H
6#define CUTELYST_COMPONENT_H
7
8#include <Cutelyst/cutelyst_global.h>
9
10#include <QtCore/qobject.h>
11
12namespace Cutelyst {
13
14class Application;
15class Context;
16class Controller;
17class Dispatcher;
18class ComponentPrivate;
19
25class CUTELYST_LIBRARY Component : public QObject
26{
28 Q_DECLARE_PRIVATE(Component)
29 Q_FLAGS(Modifiers)
30public:
32 enum Modifier {
33 None = 0 << 1,
34 OnlyExecute = 1 << 1,
35 BeforeExecute = 2 << 1,
36 AroundExecute = 3 << 1,
37 AfterExecute = 4 << 1,
38 };
39 Q_ENUM(Modifier)
40 Q_DECLARE_FLAGS(Modifiers, Modifier)
41
42
47 explicit Component(QObject *parent = nullptr);
48 virtual ~Component() override;
49
53 virtual Modifiers modifiers() const;
54
58 QString name() const;
59
63 void setName(const QString &name);
64
68 QString reverse() const;
69
73 void setReverse(const QString &reverse);
74
81 virtual bool init(Application *application, const QVariantHash &args);
82
86 bool execute(Context *c);
87
88protected:
93 explicit Component(ComponentPrivate *d, QObject *parent = nullptr);
94
98 virtual bool beforeExecute(Context *c);
99
104 virtual bool aroundExecute(Context *c, QStack<Component *> stack);
105
109 virtual bool afterExecute(Context *c);
110
114 virtual bool doExecute(Context *c);
115
119 void applyRoles(const QStack<Component *> &roles);
120
127 virtual bool dispatcherReady(const Dispatcher *dispatch, Controller *controller);
128
129protected:
130 friend class Controller;
131 ComponentPrivate
132 *d_ptr;
133};
134
135} // namespace Cutelyst
136
137#endif // CUTELYST_COMPONENT_H
The Cutelyst Application.
Definition application.h:43
The Cutelyst Component base class.
Definition component.h:26
Component(QObject *parent=nullptr)
Definition component.cpp:11
The Cutelyst Context.
Definition context.h:39
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
Q_FLAGS(...)
QObject(QObject *parent)
Q_OBJECTQ_OBJECT