Loading...
Searching...
No Matches
Engine/Plugins

Plugin interfaces, metadata, and plugin management. More...

Collaboration diagram for Engine/Plugins:

Classes

class  ml::Plugin
 Abstract base class for all Malena plugins. More...
struct  ml::PluginInfo
 Lightweight metadata record for a discovered plugin. More...
class  ml::PluginManager
 Loads, manages, and safely unloads dynamically linked plugins. More...

Macros

#define ML_EXPORT(ClassName)
 Register a Malena type with the framework at program startup.

Typedefs

template<typename Manifest, typename... Traits>
using ml::PluginWith
 Primary base class for manifest-driven plugins.

Detailed Description

Plugin interfaces, metadata, and plugin management.

Macro Definition Documentation

◆ ML_EXPORT

#define ML_EXPORT ( ClassName)
Value:
\
extern "C" { \
PLUGIN_EXPORT ml::Plugin* createPlugin() \
{ \
return ml::exports::PluginHelper<ClassName>::create(); \
} \
PLUGIN_EXPORT void destroyPlugin(ml::Plugin* p) \
{ \
ml::exports::PluginHelper<ClassName>::destroy(p); \
} \
} \
\
namespace ml::exports { \ \
inline struct _Register_##ClassName \
{ \
_Register_##ClassName() \
{ \
ml::exports::FireableHelper<ClassName>::doRegister(); \
\
static_assert( \
std::is_base_of_v<ml::Plugin, ClassName> || \
std::is_base_of_v<ml::Fireable, ClassName>, \
"[Malena] ML_EXPORT: '" #ClassName "' is not a " \
"recognised exportable Malena type. " \
"Must derive from ml::Plugin or ml::Fireable."); \
} \
} _instance_##ClassName; \ \
}
#define PLUGIN_EXPORT
Definition Plugin.h:7
Abstract base class for all Malena plugins.
Definition Plugin.h:77

Register a Malena type with the framework at program startup.

Place ML_EXPORT(ClassName) in the same header or translation unit as the class definition. It handles two distinct registration paths:

  • Plugin — emits extern "C" factory symbols (createPlugin / destroyPlugin) so that PluginManager can load the class from a shared library via dlopen / LoadLibrary.
  • Fireable — registers a singleton dispatcher instance with Fireable::_register so that AppManager dispatches events to it.
  • Plugin + Fireable — the plugin path takes precedence; PluginManager registers the Fireable aspect at load time.
  • Neither — a static_assert fires at compile time.
Parameters
ClassNameThe class to register. Must be fully defined at the point where ML_EXPORT appears.
See also
PluginWith, Fireable, PluginManager

Definition at line 329 of file Plugin.h.

Typedef Documentation

◆ PluginWith

template<typename Manifest, typename... Traits>
using ml::PluginWith
Initial value:
std::conditional_t<
TraitsHaveCore<Traits...>::value,
PluginBaseWithCore<Manifest, Traits...>,
PluginBase<Manifest, Traits...>
>
Base class for all Malena manifests.
Definition Manifest.h:81

Primary base class for manifest-driven plugins.

PluginWith<Manifest> is the recommended way to create a Malena plugin. It wires in the manifest's resource enums, flag/state machinery, and satisfies the Plugin interface automatically.

class MyPlugin : public ml::PluginWith<MyManifest>
{
public:
void onLoad() override { /* set up components *\/ }
* void onUnload() override { /* clean up *\/ }
* };
* ML_EXPORT(MyPlugin)
*
std::conditional_t< TraitsHaveCore< Traits... >::value, PluginBaseWithCore< Manifest, Traits... >, PluginBase< Manifest, Traits... > > PluginWith
Primary base class for manifest-driven plugins.
Definition Plugin.h:268
Template Parameters
ManifestA Manifest subclass with name and version static constexpr members.
TraitsOptional extra traits (e.g. Messenger, Fadeable).
See also
Plugin, PluginManager, ML_EXPORT

Definition at line 268 of file Plugin.h.