cutelyst 4.0.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);
29 virtual ~Engine();
30
34 [[nodiscard]] Application *app() const;
35
40 [[nodiscard]] virtual int workerId() const = 0;
41
45 [[nodiscard]] int workerCore() const;
46
54 [[nodiscard]] inline bool isZeroWorker() const;
55
59 [[nodiscard]] QVariantMap opts() const;
60
66 [[nodiscard]] QVariantMap config(const QString &entity) const;
67
71 void setConfig(const QVariantMap &config);
72
76 [[nodiscard]] static QVariantMap loadIniConfig(const QString &filename);
77
81 [[nodiscard]] static QVariantMap loadJsonConfig(const QString &filename);
82
88 virtual quint64 time();
89
97 void processRequest(EngineRequest *request);
98
102 static const char *httpStatusMessage(quint16 status, int *len = nullptr);
103
104Q_SIGNALS:
113
114protected:
124 bool initApplication();
125
138 bool postForkApplication();
139
143 [[nodiscard]] Headers &defaultHeaders();
144
145 EnginePrivate *d_ptr;
146
147private:
148 Q_DECLARE_PRIVATE(Engine)
149 friend class Application;
150 friend class Response;
151
156 virtual bool init() = 0;
157};
158
159inline bool Engine::isZeroWorker() const
160{
161 return !workerId() && !workerCore();
162}
163
164} // namespace Cutelyst
The Cutelyst Application.
Definition: application.h:43
The Cutelyst Engine.
Definition: engine.h:20
int workerCore() const
Each worker process migth have a number of worker cores (threads), a single process with two worker t...
Definition: engine.cpp:89
virtual int workerId() const =0
The id is the number of the spawned engine process, a single process workerId = 0,...
bool isZeroWorker() const
Definition: engine.h:159
void processRequestAsync(Cutelyst::EngineRequest *request)
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:8