Loading...
Searching...
No Matches
ml::ApplicationWith< Manifest > Class Template Referenceabstract

Entry point for Malena applications with a manifest. More...

#include <Application.h>

Inheritance diagram for ml::ApplicationWith< Manifest >:

Public Types

enum  Architecture { MVC , EDA , ECS }
 Architectural style hint passed at construction. More...
using Resources = ml::ManifestResources<Manifest>
 Unified resource accessor — Resources::get(Images::Icon).

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.
template<typename EnumType>
static auto get (EnumType key) -> std::enable_if_t< !is_asset_enum< Manifest, EnumType >::value, decltype(ConfigManager< Manifest >::get(key))>
 Retrieve a config value by enum key → ConfigManager.
template<typename EnumType>
static auto get (EnumType key) -> std::enable_if_t< is_asset_enum< Manifest, EnumType >::value, const_ref_t< decltype(AssetsManager< Manifest >::get(key))> >
 Retrieve an asset by enum key → AssetsManager.
static void reset ()
 Full application reset — clears events, messages, and components.
template<typename EnumType>
static std::enable_if_t< is_sounds_enum< Manifest, EnumType >::value > unload (EnumType key)
template<typename EnumType>
static std::enable_if_t< is_fonts_enum< Manifest, EnumType >::value > unload (EnumType key)
template<typename EnumType>
static std::enable_if_t< is_images_enum< Manifest, EnumType >::value > unload (EnumType key)

Detailed Description

template<typename Manifest>
class ml::ApplicationWith< Manifest >

Entry point for Malena applications with a manifest.

Extends Application with manifest support — injects Resources::get() and all manifest enum aliases into scope automatically. Use when your application has global resources (icon, main font, app-wide config).

class MyManifest : public ml::Manifest
{
public:
static constexpr const char* name = "My App";
static constexpr const char* version = "1.0.0";
enum class Images { Icon };
enum class Fonts { Main };
enum class Text { WindowTitle };
enum class Ints { TargetFPS };
private:
inline static const auto _ = [](){
set(Images::Icon, "assets/icon.png");
set(Fonts::Main, "assets/main.ttf");
set(Text::WindowTitle, std::string("My App"));
set(Ints::TargetFPS, 60);
return 0;
}();
};
class MyApp : public ml::ApplicationWith<MyManifest>
{
public:
MyApp() : ml::ApplicationWith<MyManifest>(
1280, 720, 32,
Resources::get(Text::WindowTitle)) {}
void initialization() override
{
auto& icon = Resources::get(Images::Icon);
auto& font = Resources::get(Fonts::Main);
int fps = Resources::get(Ints::TargetFPS);
}
void registerEvents() override { ... }
};
ml::ManifestResources< Manifest > Resources
Unified resource accessor — Resources::get(Images::Icon).
void registerEvents() override=0
Attach event callbacks to components and framework objects.
void initialization() override=0
Create and register all components and resources.
Base class for all Malena manifests.
Definition Manifest.h:81
static void set(EnumType key, const char *filepath)
Register an asset file path.
static auto get(EnumType key) -> std::enable_if_t< is_asset_enum< Manifest, EnumType >::value, const_ref_t< decltype(AssetsManager< Manifest >::get(key))> >
Retrieve an asset by enum key → AssetsManager.
Template Parameters
ManifestA Manifest subclass declaring app-wide resources and configuration.
See also
Application, ApplicationBase, Resources

Definition at line 180 of file Application.h.

Member Typedef Documentation

◆ Resources

template<typename Manifest>
using ml::ApplicationWith< Manifest >::Resources = ml::ManifestResources<Manifest>

Unified resource accessor — Resources::get(Images::Icon).

Definition at line 185 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]

template<typename Manifest>
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]

template<typename Manifest>
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]

template<typename Manifest>
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.

◆ get() [1/2]

template<typename Manifest>
template<typename EnumType>
auto ml::ManifestResources< Manifest >::get ( EnumType key) -> std::enable_if_t< !is_asset_enum< Manifest, EnumType >::value, decltype(ConfigManager< Manifest >::get(key))>
inlinestaticinherited

Retrieve a config value by enum key → ConfigManager.

Return type is inferred from ConfigManager::get()Text gives const std::string&, Ints gives int, etc.

Definition at line 122 of file ManifestResources.h.

◆ get() [2/2]

template<typename Manifest>
template<typename EnumType>
auto ml::ManifestResources< Manifest >::get ( EnumType key) -> std::enable_if_t< is_asset_enum< Manifest, EnumType >::value, const_ref_t< decltype(AssetsManager< Manifest >::get(key))> >
inlinestaticinherited

Retrieve an asset by enum key → AssetsManager.

Return type is explicitly const T& — taking & gives const T* with no ambiguity, suitable for SFML functions that take const sf::Texture* etc.

Definition at line 107 of file ManifestResources.h.

◆ initialization()

template<typename Manifest>
void ml::ApplicationWith< Manifest >::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()

template<typename Manifest>
void ml::ApplicationWith< Manifest >::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.

◆ unload() [1/3]

template<typename Manifest>
template<typename EnumType>
std::enable_if_t< is_sounds_enum< Manifest, EnumType >::value > ml::ManifestResources< Manifest >::unload ( EnumType key)
inlinestaticinherited

Definition at line 148 of file ManifestResources.h.

◆ unload() [2/3]

template<typename Manifest>
template<typename EnumType>
std::enable_if_t< is_fonts_enum< Manifest, EnumType >::value > ml::ManifestResources< Manifest >::unload ( EnumType key)
inlinestaticinherited

Definition at line 141 of file ManifestResources.h.

◆ unload() [3/3]

template<typename Manifest>
template<typename EnumType>
std::enable_if_t< is_images_enum< Manifest, EnumType >::value > ml::ManifestResources< Manifest >::unload ( EnumType key)
inlinestaticinherited

Definition at line 134 of file ManifestResources.h.


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