Cutelyst
2.13.0
Cutelyst
controller.h
1
/*
2
* Copyright (C) 2013-2017 Daniel Nicoletti <dantti12@gmail.com>
3
*
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
8
*
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
13
*
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
*/
18
#ifndef CUTELYST_CONTROLLER_H
19
#define CUTELYST_CONTROLLER_H
20
21
#include <QObject>
22
23
#include <Cutelyst/cutelyst_global.h>
24
#include <Cutelyst/action.h>
25
#include <Cutelyst/context.h>
26
#include <Cutelyst/request.h>
27
#include <Cutelyst/response.h>
28
29
#define STR(X) #X
30
#define C_PATH(X, Y) Q_CLASSINFO(STR(X ## _Path), STR(Y))
31
#define C_NAMESPACE(value) Q_CLASSINFO("Namespace", value)
32
#define C_ATTR(X, Y) Q_CLASSINFO(STR(X), STR(Y)) Q_INVOKABLE
33
34
# define CActionFor(str) \
35
([this]() -> Cutelyst::Action * { \
36
static thread_local Cutelyst::Action *action = \
37
Cutelyst::Controller::actionFor(str); \
38
return action; \
39
}()) \
40
41
42
namespace
Cutelyst
{
43
44
class
ControllerPrivate;
102
class
CUTELYST_LIBRARY
Controller
:
public
QObject
103
{
104
Q_OBJECT
105
public
:
109
explicit
Controller
(QObject *parent =
nullptr
);
110
virtual
~
Controller
();
111
121
QString ns()
const
;
122
129
Action
*actionFor(
const
QString &name)
const
;
130
135
ActionList
actions()
const
;
136
140
bool
operator==(
const
char
*className);
141
142
protected
:
151
virtual
bool
preFork(
Application
*app);
152
161
virtual
bool
postFork(
Application
*app);
162
168
bool
_DISPATCH(
Context
*c);
169
170
ControllerPrivate *d_ptr;
171
172
private
:
173
Q_DECLARE_PRIVATE(
Controller
)
174
friend
class
Application
;
175
friend
class
Dispatcher
;
176
};
177
178
}
179
180
#endif // CUTELYST_CONTROLLER_H
Cutelyst::Controller
Cutelyst Controller base class
Definition:
controller.h:102
Cutelyst::Application
The Cutelyst Application.
Definition:
application.h:55
Cutelyst::Dispatcher
The Cutelyst Dispatcher.
Definition:
dispatcher.h:40
Cutelyst::Context
The Cutelyst Context.
Definition:
context.h:50
Cutelyst
The Cutelyst namespace holds all public Cutelyst API.
Definition:
Mainpage.dox:7
Cutelyst::Action
This class represents a Cutelyst Action.
Definition:
action.h:47
Cutelyst::ActionList
QVector< Action * > ActionList
Definition:
action.h:166
Generated on Fri Sep 11 2020 14:33:05 for Cutelyst by
1.8.17