cutelyst 4.3.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
engine.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/Headers>
8#include <Cutelyst/cutelyst_global.h>
9
10#include <QHostAddress>
11#include <QObject>
12
13namespace Cutelyst {
14
15class Application;
16class Context;
17class EngineRequest;
18class EnginePrivate;
19class CUTELYST_LIBRARY Engine : public QObject
20{
21 Q_OBJECT
22public:
28 explicit Engine(Application *app, int workerCore, const QVariantMap &opts);
32 virtual ~Engine();
33
37 [[nodiscard]] Application *app() const;
38
48 [[nodiscard]] virtual int workerId() const = 0;
49
57 [[nodiscard]] int workerCore() const;
58
66 [[nodiscard]] inline bool isZeroWorker() const;
67
71 [[nodiscard]] QVariantMap opts() const;
72
79 [[nodiscard]] QVariantMap config(const QString &entity) const;
80
84 void setConfig(const QVariantMap &config);
85
89 [[nodiscard]] static QVariantMap loadIniConfig(const QString &filename);
90
94 [[nodiscard]] static QVariantMap loadJsonConfig(const QString &filename);
95
101 void processRequest(EngineRequest *request);
102
107 static const char *httpStatusMessage(quint16 status, int *len = nullptr);
108
109Q_SIGNALS:
118
119protected:
124 bool initApplication();
125
136 bool postForkApplication();
137
141 [[nodiscard]] Headers &defaultHeaders();
142
143 EnginePrivate *d_ptr;
144
145private:
146 Q_DECLARE_PRIVATE(Engine)
147 friend class Application;
148 friend class Response;
149
153 virtual bool init() = 0;
154};
155
156inline bool Engine::isZeroWorker() const
157{
158 return !workerId() && !workerCore();
159}
160
161} // namespace Cutelyst
The Cutelyst application.
Definition application.h:66
The Cutelyst Engine.
Definition engine.h:20
int workerCore() const
Definition engine.cpp:67
virtual int workerId() const =0
bool isZeroWorker() const
Definition engine.h:156
void processRequestAsync(Cutelyst::EngineRequest *request)
Container for HTTP headers.
Definition headers.h:24
A Cutelyst response.
Definition response.h:29
The Cutelyst namespace holds all public Cutelyst API.