1313
1414namespace nativeapi {
1515
16-
1716/* *
1817 * @brief Application is a singleton class that manages the application lifecycle
1918 *
@@ -50,7 +49,7 @@ class Application : public EventEmitter<ApplicationEvent> {
5049 * @code
5150 * // Usage example:
5251 * auto& app = Application::GetInstance();
53- * app.Initialize(options );
52+ * int exit_code = app.Run( );
5453 * @endcode
5554 */
5655 static Application& GetInstance ();
@@ -64,40 +63,38 @@ class Application : public EventEmitter<ApplicationEvent> {
6463 virtual ~Application ();
6564
6665 /* *
67- * @brief Initialize the application
68- *
69- * Sets up the application with default configuration. This method
70- * should be called before any other application operations. It sets up
71- * platform-specific initialization and emits an ApplicationStartedEvent.
66+ * @brief Run the application main event loop
7267 *
73- * @return true if initialization succeeded, false otherwise
68+ * Starts the main event loop and blocks until the application exits.
69+ * This method handles platform-specific event processing and coordination
70+ * between different managers.
7471 *
75- * @throws std::runtime_error if initialization fails due to system limitations
72+ * @return Exit code of the application (0 for success)
7673 *
7774 * @code
7875 * auto& app = Application::GetInstance();
79- * if (app.Initialize()) {
80- * // Application initialized successfully
81- * }
76+ * int exit_code = app.Run();
8277 * @endcode
8378 */
84- bool Initialize ();
79+ int Run ();
8580
8681 /* *
87- * @brief Run the application main event loop
82+ * @brief Run the application with the specified window
8883 *
89- * Starts the main event loop and blocks until the application exits.
90- * This method handles platform-specific event processing and coordination
91- * between different managers .
84+ * Starts the main event loop with the given window and blocks until the
85+ * application exits. This method sets the window as the primary window
86+ * and starts the event loop .
9287 *
88+ * @param window The window to run the application with
9389 * @return Exit code of the application (0 for success)
9490 *
9591 * @code
9692 * auto& app = Application::GetInstance();
97- * int exit_code = app.Run();
93+ * auto window = WindowManager::GetInstance().Create(options);
94+ * int exit_code = app.Run(window);
9895 * @endcode
9996 */
100- int Run ();
97+ int Run (std::shared_ptr<Window> window );
10198
10299 /* *
103100 * @brief Request the application to quit
@@ -121,7 +118,6 @@ class Application : public EventEmitter<ApplicationEvent> {
121118 */
122119 bool IsRunning () const ;
123120
124-
125121 /* *
126122 * @brief Check if this is a single instance application
127123 *
@@ -191,12 +187,11 @@ class Application : public EventEmitter<ApplicationEvent> {
191187 */
192188 std::vector<std::shared_ptr<Window>> GetAllWindows () const ;
193189
194-
195190 private:
196191 /* *
197192 * @brief Private constructor to enforce singleton pattern
198193 *
199- * Initializes the Application instance and sets up platform-specific
194+ * Automatically initializes the Application instance and sets up platform-specific
200195 * event monitoring. This constructor is private to prevent direct instantiation.
201196 */
202197 Application ();
@@ -216,7 +211,6 @@ class Application : public EventEmitter<ApplicationEvent> {
216211 class Impl ;
217212 std::unique_ptr<Impl> pimpl_;
218213
219-
220214 /* *
221215 * @brief Application state
222216 */
@@ -229,15 +223,24 @@ class Application : public EventEmitter<ApplicationEvent> {
229223 */
230224 std::shared_ptr<Window> primary_window_;
231225
232- /* *
233- * @brief Clean up platform-specific event monitoring
234- *
235- * Stops event monitoring and cleans up associated resources.
236- * This is called during destruction.
237- */
238- void CleanupEventMonitoring ();
239-
240226 private:
241227};
242228
229+ /* *
230+ * @brief Convenience function to run the application with the specified window
231+ *
232+ * This is equivalent to calling Application::GetInstance().Run(window).
233+ * This function provides a simple way to run an application without
234+ * explicitly accessing the singleton.
235+ *
236+ * @param window The window to run the application with
237+ * @return Exit code of the application (0 for success)
238+ *
239+ * @code
240+ * auto window = WindowManager::GetInstance().Create(options);
241+ * int exit_code = RunApp(window);
242+ * @endcode
243+ */
244+ int RunApp (std::shared_ptr<Window> window);
245+
243246} // namespace nativeapi
0 commit comments