5 #ifndef CUTELYST_APPLICATION_H 6 #define CUTELYST_APPLICATION_H 8 #include <Cutelyst/cutelyst_export.h> 10 #include <QtCore/QLocale> 11 #include <QtCore/QObject> 12 #include <QtCore/QVariant> 13 #include <QtCore/QVector> 19 #define CUTELYST_APPLICATION(x) \ 20 Q_PLUGIN_METADATA(x) \ 21 Q_INTERFACES(Cutelyst::Application) 35 class ApplicationPrivate;
65 class CUTELYST_EXPORT Application :
public QObject 68 Q_DECLARE_PRIVATE(Application)
84 explicit Application(
QObject *parent =
nullptr);
89 virtual ~Application();
119 Dispatcher *dispatcher() const noexcept;
126 QVector<DispatchType *> dispatchers() const noexcept;
131 QVector<Plugin *> plugins() const noexcept;
136 template <typename T>
139 const auto pluginsConst = plugins();
140 for (Plugin *plugin : pluginsConst) {
141 auto p = qobject_cast<T>(plugin);
159 QVariantMap config() const noexcept;
181 bool inited() const noexcept;
186 Engine *engine() const noexcept;
192 Component *createComponentPlugin(const
QString &name,
QObject *parent =
nullptr);
197 static const
char *cutelystVersion() noexcept;
279 const
char *sourceText,
280 const
char *disambiguation =
nullptr,
315 void loadTranslations(const
QString &filename,
355 const QString &prefix = QStringLiteral(
"."),
356 const QString &suffix = QStringLiteral(
".qm"));
394 [[nodiscard]]
QLocale defaultLocale() const noexcept;
404 void setDefaultLocale(const
QLocale &locale);
441 virtual
bool postFork();
448 Headers &defaultHeaders() noexcept;
453 void addXCutelystVersionHeader();
462 bool registerPlugin(Plugin *plugin);
474 bool registerController(Controller *controller);
483 bool registerView(View *view);
489 bool registerDispatcher(DispatchType *dispatcher);
501 void beforePrepareAction(
Cutelyst::Context *c,
bool *skipMethod);
507 void beforeDispatch(
Cutelyst::Context *c);
513 void afterDispatch(
Cutelyst::Context *c);
519 void preForked(
Cutelyst::Application *app);
524 void postForked(
Cutelyst::Application *app);
531 void shuttingDown(
Cutelyst::Application *app);
547 friend class Context;
552 bool setup(Engine *engine);
557 void handleRequest(
Cutelyst::EngineRequest *request);
562 bool enginePostFork();
564 ApplicationPrivate *d_ptr;
569 #define CutelystApplicationInterface_iid "org.cutelyst.CutelystApplicationInterface" 573 #endif // CUTELYST_APPLICATION_H
The Cutelyst namespace holds all public Cutelyst API.
The Cutelyst application.