pure-cpp 1.0.0
A C++ physics simulation benchmark comparing performance with Python implementations
app_manager.hpp
1#ifndef APP_MANAGER_HPP
2#define APP_MANAGER_HPP
3
4#include <QApplication>
5#include <QMainWindow>
6#include <QObject>
7#include <QPointer>
8#include <memory>
9
10#include "cmd_line_parser.hpp"
11#include "config.hpp"
12#include "logger.hpp"
13#include "qml_bridge.hpp"
15
16namespace App {
17 /**
18 * \brief Orchestrates the application's lifecycle: setup, execution, and
19 * cleanup.
20 *
21 * This class encapsulates the initialisation of translations, argument
22 * parsing, logging, and the QML interface, simplifying the global `main()`
23 * function.
24 * \ingroup AppLifecycle
25 */
26 class AppManager : public QObject { // NOLINT
27 Q_OBJECT
28
29 public:
30 AppManager();
31
32 /**
33 * \brief Sets up all application components before running.
34 * \return True on success, false on failure or if --help/--version
35 * was requested.
36 */
37 bool setup();
38
39 /**
40 * \brief Runs the main application event loop.
41 * \return The application exit code.
42 */
43 int run();
44
45 private slots:
46 /**
47 * \brief Performs cleanup after the event loop has finished.
48 */
49 void cleanup();
50
51 private:
52 /// \brief The logger for the application.
53 std::unique_ptr<AppUtils::Logger> logger_;
54 /// \brief The command line arguments for the application.
55 std::unique_ptr<CmdLine::CmdLineArgs> args_;
56 /// \brief The QML bridge for exposing C++ functionality.
57 QPointer<Window::QmlBridge> bridge_;
58 /// \brief The main window (stored for proper cleanup order).
59 QMainWindow* mainWindow_;
60 };
61} // namespace App
62#endif // APP_MANAGER_HPP
Orchestrates the application's lifecycle: setup, execution, and cleanup.
Definition: app_manager.hpp:26
QPointer< Window::QmlBridge > bridge_
The QML bridge for exposing C++ functionality.
Definition: app_manager.hpp:57
int run()
Runs the main application event loop.
Definition: app_manager.cpp:73
bool setup()
Sets up all application components before running.
Definition: app_manager.cpp:39
QMainWindow * mainWindow_
The main window (stored for proper cleanup order).
Definition: app_manager.hpp:59
void cleanup()
Performs cleanup after the event loop has finished.
std::unique_ptr< AppUtils::Logger > logger_
The logger for the application.
Definition: app_manager.hpp:53
AppManager()
Constructs the application manager and sets application-wide metadata.
Definition: app_manager.cpp:26
std::unique_ptr< CmdLine::CmdLineArgs > args_
The command line arguments for the application.
Definition: app_manager.hpp:55
Command-line argument parsing and validation.
Manages application logging based on command-line arguments.
Bridge class to expose C++ functionality to QML.
Helper class for loading application and Qt translations.