Loading...
Searching...
No Matches
ml::AppManager Class Reference

Drives the application main loop and coordinates all framework managers. More...

#include <AppManager.h>

Inheritance diagram for ml::AppManager:

Public Types

enum  Architecture { MVC , EDA , ECS }
 Architectural style hint passed at construction. More...

Public Member Functions

 AppManager (const sf::VideoMode &videoMode, const std::string &title, UIController &appLogic, sf::RenderWindow &window=WindowManager::getWindow(), Architecture architecture=MVC)
 Construct an AppManager with an explicit controller and window.
virtual ~AppManager ()=default
void run () override
 Enter the main loop and run until the window is closed.

Detailed Description

Drives the application main loop and coordinates all framework managers.

AppManager owns the SFML render window and runs the core application lifecycle:

  1. Calls UIController::initialization() and UIController::registerEvents() before entering the loop.
  2. Each frame, polls SFML events and distributes them via fireInputEvents().
  3. Fires the per-frame update event via fireUpdateEvents().
  4. Clears the window, calls draw(), and presents the frame.

AppManager implements the Manager interface, so it participates in the same event-distribution protocol as other framework managers.

Architecture modes

The Architecture enum lets the framework know which structural style the application uses.

Value Meaning
MVC Model-View-Controller — default for most UI applications
EDA Event-Driven Architecture — pure message/event flow
ECS Entity-Component-System — activates the ECS subsystem

Typical use

Most applications do not instantiate AppManager directly. Instead, inherit from ml::Application, which combines AppManager and UIController into a single convenient base class.

For projects that separate the runner from the UI logic:

MyController controller;
ml::AppManager runner(sf::VideoMode({1280, 720}), "My App", controller);
runner.run();
Drives the application main loop and coordinates all framework managers.
Definition AppManager.h:59
void run() override
Enter the main loop and run until the window is closed.
See also
Application, UIController, Manager, WindowManager

Definition at line 58 of file AppManager.h.

Member Enumeration Documentation

◆ Architecture

Architectural style hint passed at construction.

Informs the framework which structural pattern the application follows. Defaults to MVC.

Enumerator
MVC 

Model-View-Controller.

EDA 

Event-Driven Architecture.

ECS 

Entity-Component-System.

Definition at line 76 of file AppManager.h.

Constructor & Destructor Documentation

◆ AppManager()

ml::AppManager::AppManager ( const sf::VideoMode & videoMode,
const std::string & title,
UIController & appLogic,
sf::RenderWindow & window = WindowManager::getWindow(),
Architecture architecture = MVC )

Construct an AppManager with an explicit controller and window.

Calls controller.initialization() then controller.registerEvents() before returning. The window parameter defaults to WindowManager::getWindow() so that the framework's centralized window is used unless you explicitly provide your own.

Parameters
videoModeSFML video mode (resolution + bit depth).
titleWindow title string.
appLogicController that provides initialization() and registerEvents() implementations.
windowRender window to use. Defaults to the framework window.
architectureStructural pattern hint. Defaults to MVC.

◆ ~AppManager()

virtual ml::AppManager::~AppManager ( )
virtualdefault

Member Function Documentation

◆ run()

void ml::AppManager::run ( )
overridevirtual

Enter the main loop and run until the window is closed.

Each iteration of the loop:

  1. Polls all pending SFML events and passes each to fireInputEvents().
  2. Calls fireUpdateEvents() for the per-frame update tick.
  3. Clears the window, calls draw() on all registered components, and displays the frame.

Returns when the SFML window is closed or window.close() is called.

Implements ml::Manager.


The documentation for this class was generated from the following file: