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