5#ifndef CUTELYST_APPLICATION_H
6#define CUTELYST_APPLICATION_H
8#include <Cutelyst/cutelyst_global.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)
35class ApplicationPrivate;
69 QVector<Controller *> controllers()
const noexcept;
74 View *view(
const QString &name)
const;
79 View *view(QStringView name = {})
const;
84 QVariant config(
const QString &key,
const QVariant &defaultValue = {})
const;
96 QVector<DispatchType *> dispatchers()
const noexcept;
101 QVector<Plugin *> plugins()
const noexcept;
106 template <
typename T>
109 const auto pluginsConst = plugins();
110 for (
Plugin *plugin : pluginsConst) {
111 auto p = qobject_cast<T>(plugin);
123 QVariantMap config() const noexcept;
128 QString pathTo(const QString &path) const;
133 QString pathTo(const QStringList &path) const;
138 bool inited() const noexcept;
143 Engine *engine() const noexcept;
149 Component *createComponentPlugin(const QString &name, QObject *parent =
nullptr);
154 static const
char *cutelystVersion() noexcept;
184 void addTranslator(const QLocale &locale, QTranslator *translator);
195 void addTranslator(const QString &locale, QTranslator *translator);
204 void addTranslators(const QLocale &locale, const QVector<QTranslator *> &translators);
217 QString translate(const QLocale &locale,
219 const
char *sourceText,
220 const
char *disambiguation =
nullptr,
251 void loadTranslations(const QString &filename,
252 const QString &directory = QString(),
253 const QString &prefix = QString(),
254 const QString &suffix = QString());
285 QVector<QLocale> loadTranslationsFromDir(const QString &filename,
286 const QString &directory = QString(),
287 const QString &prefix = QStringLiteral("."),
288 const QString &suffix = QStringLiteral(".qm"));
315 QVector<QLocale> loadTranslationsFromDirs(const QString &directory, const QString &filename);
350 virtual
bool postFork();
357 Headers &defaultHeaders() noexcept;
362 void addXCutelystVersionHeader();
371 bool registerPlugin(
Plugin *plugin);
383 bool registerController(
Controller *controller);
392 bool registerView(
View *view);
449 void setConfig(const QString &key, const QVariant &value);
457 bool setup(
Engine *engine);
467 bool enginePostFork();
469 ApplicationPrivate *d_ptr;
474#define CutelystApplicationInterface_iid "org.cutelyst.CutelystApplicationInterface"
The Cutelyst Application.
T plugin()
Returns the registered plugin that casts to the template type T.
The Cutelyst Component base class.
Cutelyst Controller base class
Cutelyst View abstract view component
The Cutelyst namespace holds all public Cutelyst API.