Internal base class for all Malena applications. More...
#include <Application.h>
Public Types | |
| enum | Architecture { MVC , EDA , ECS } |
| Architectural style hint passed at construction. More... | |
Public Member Functions | |
| ApplicationBase (const sf::VideoMode &videoMode, const std::string &title) | |
Construct from an SFML video mode, using *this as the controller. | |
| ApplicationBase (const sf::VideoMode &videoMode, const std::string &title, UIController &appLogic, sf::RenderWindow &window=WindowManager::getWindow()) | |
Construct with a separate UIController and explicit video mode. | |
| ApplicationBase (unsigned int screenWidth, unsigned int screenHeight, unsigned int bitDepth, const std::string &title) | |
| Construct from pixel dimensions and bit depth. | |
| void | addComponent (Core &component) |
Register a Core object with the application's component manager. | |
| void | initialization () override=0 |
| Create and register all components and resources. | |
| void | onUpdate (std::function< void()> f) |
| Register a callback invoked every frame during the update tick. | |
| void | registerEvents () override=0 |
| Attach event callbacks to components and framework objects. | |
| void | run () override |
| Enter the main loop and run until the window is closed. | |
Static Public Member Functions | |
| static void | clearEvents () |
| Clear all event subscriptions across the entire application. | |
| static void | reset () |
| Full application reset — clears events, messages, and components. | |
Internal base class for all Malena applications.
Do not inherit directly. Use ml::Application or ml::ApplicationWith.
Definition at line 31 of file Application.h.
|
inherited |
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.
| ml::ApplicationBase::ApplicationBase | ( | const sf::VideoMode & | videoMode, |
| const std::string & | title, | ||
| UIController & | appLogic, | ||
| sf::RenderWindow & | window = WindowManager::getWindow() ) |
Construct with a separate UIController and explicit video mode.
| ml::ApplicationBase::ApplicationBase | ( | unsigned int | screenWidth, |
| unsigned int | screenHeight, | ||
| unsigned int | bitDepth, | ||
| const std::string & | title ) |
Construct from pixel dimensions and bit depth.
| ml::ApplicationBase::ApplicationBase | ( | const sf::VideoMode & | videoMode, |
| const std::string & | title ) |
Construct from an SFML video mode, using *this as the controller.
| void ml::ApplicationBase::addComponent | ( | Core & | component | ) |
Register a Core object with the application's component manager.
|
static |
Clear all event subscriptions across the entire application.
|
overridepure virtualinherited |
Create and register all components and resources.
Implement this method to construct the objects your application needs and register them with the appropriate managers (e.g., via addComponent). This method runs before registerEvents(), so every object you plan to subscribe to will already exist by the time callbacks are attached.
Implements ml::Controller.
Implemented in ml::Application, and ml::ApplicationWith< Manifest >.
|
inherited |
Register a callback invoked every frame during the update tick.
Equivalent to calling onUpdate on a component, but scoped to the controller itself. Use this for frame-level logic that is not tied to a specific component — for example, polling game state, advancing a timer, or orchestrating scene transitions.
| f | Callback with no arguments, invoked once per frame. |
|
overridepure virtualinherited |
Attach event callbacks to components and framework objects.
Implement this method to wire up onClick, onHover, onUpdate, onMessage, and any other subscriptions. Called immediately after initialization() by AppManager before the main loop begins.
Implements ml::Controller.
Implemented in ml::Application, and ml::ApplicationWith< Manifest >.
|
static |
Full application reset — clears events, messages, and components.
Tears down all framework state in the correct order:
After reset(), call initialization() and registerEvents() to rebuild the scene.
|
overridevirtualinherited |
Enter the main loop and run until the window is closed.
Each iteration of the loop:
fireInputEvents().fireUpdateEvents() for the per-frame update tick.draw() on all registered components, and displays the frame.Returns when the SFML window is closed or window.close() is called.
Implements ml::Manager.