Loading...
Searching...
No Matches
ml::Application Class Referenceabstract

Primary entry point for Malena applications without a manifest. More...

#include <Application.h>

Inheritance diagram for ml::Application:

Public Types

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

Public Member Functions

void addComponent (Core &component)
 Register a Core object with the application's component manager.
 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 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.

Detailed Description

Primary entry point for Malena applications without a manifest.

Combines AppManager and UIController into a single class. Override initialization() and registerEvents() to build your scene.

class MyApp : public ml::Application
{
public:
MyApp() : ml::Application(1280, 720, 32, "My App") {}
void initialization() override
{
_box.setSize({200.f, 100.f});
addComponent(_box);
}
void registerEvents() override
{
_box.onClick([]{ std::cout << "clicked!\n"; });
}
private:
ml::Rectangle _box;
};
void addComponent(Core &component)
Register a Core object with the application's component manager.
Primary entry point for Malena applications without a manifest.
void registerEvents() override=0
Attach event callbacks to components and framework objects.
void initialization() override=0
Create and register all components and resources.
Definition Component.h:18
See also
ApplicationWith, AppManager, UIController

Definition at line 115 of file Application.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.

Member Function Documentation

◆ addComponent()

void ml::ApplicationBase::addComponent ( Core & component)
inherited

Register a Core object with the application's component manager.

◆ ApplicationBase() [1/3]

ml::ApplicationBase::ApplicationBase ( const sf::VideoMode & videoMode,
const std::string & title )

Construct from an SFML video mode, using *this as the controller.

◆ ApplicationBase() [2/3]

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.

◆ ApplicationBase() [3/3]

ml::ApplicationBase::ApplicationBase ( unsigned int screenWidth,
unsigned int screenHeight,
unsigned int bitDepth,
const std::string & title )

Construct from pixel dimensions and bit depth.

◆ clearEvents()

void ml::ApplicationBase::clearEvents ( )
staticinherited

Clear all event subscriptions across the entire application.

◆ initialization()

void ml::Application::initialization ( )
overridepure virtual

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::UIController.

◆ onUpdate()

void ml::UIController::onUpdate ( std::function< void()> f)
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.

Parameters
fCallback with no arguments, invoked once per frame.

◆ registerEvents()

void ml::Application::registerEvents ( )
overridepure virtual

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::UIController.

◆ reset()

void ml::ApplicationBase::reset ( )
staticinherited

Full application reset — clears events, messages, and components.

Tears down all framework state in the correct order:

  1. All event subscriptions
  2. All message subscriptions
  3. All registered components

After reset(), call initialization() and registerEvents() to rebuild the scene.

Note
Does NOT close the window or restart the main loop.

◆ run()

void ml::AppManager::run ( )
overridevirtualinherited

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: