Skip to content

Latest commit

 

History

History
111 lines (87 loc) · 1.73 KB

File metadata and controls

111 lines (87 loc) · 1.73 KB

The app and the builder

The framework provides an easy way to customize your application before it launches. The app builder should be the first point of entry for any application.

Plugins

The bare-bone builder does not provide any features, but one customization point. Everything is build around that.

"Hello World!" using the app builder
struct CustomPlugin {
    auto say_hello() -> void
    {
        std::println("Hello World!");
    }
};

ddge::app::create()
    .plug_in(CustomPlugin{})
    .say_hello();
Hello World!

Builder plugin

Plugins are also allowed to have a build() method which takes an App as a parameter and returns it.

struct CustomPlugin {
    auto build(auto app)
    {
        std::println("Building custom plugin...");
        return app;
    }
};

auto app =
    ddge::app::create()
        .plug_in(CustomPlugin{})
        .build();
Building custom plugin...

Add-ons

The equivalent of plugins for an app are the add-ons.

"Hello World!" using an addon
struct CustomAddon {
    auto say_hello() -> void
    {
        std::println("Hello World!");
    }
};

auto app = ddge::app::create().build();

auto customized_app = app.add_on(CustomAddon{});

customized_app.say_hello();
Hello World!

It is also a good practice to combine plugins and addons.

struct CustomAddon {
    auto say_hello() -> void
    {
        std::println("Hello World!");
    }
};

struct CustomPlugin {
    auto build(auto app)
    {
        return app.add_on(CustomAddon{});
    }
};

ddge::app::create()
    .plug_in(CustomPlugin{})
    .build()
    .say_hello();
Hello World!