Loading...
Searching...
No Matches
ml::MLExport< T > Struct Template Reference

Template alternative to ML_EXPORT for registering Malena types in .cpp files. More...

#include <MLExport.h>

Detailed Description

template<typename T>
struct ml::MLExport< T >

Template alternative to ML_EXPORT for registering Malena types in .cpp files.

MLExport<T> provides the same registration behaviour as ML_EXPORT but uses explicit template instantiation syntax rather than a macro. Use it in a .cpp file:

// ScoreFireable.cpp
#include "ScoreFireable.h"
Template alternative to ML_EXPORT for registering Malena types in .cpp files.
Definition MLExport.h:74

This is exactly equivalent to:

ML_EXPORT(ScoreFireable)
#define ML_EXPORT(ClassName)
Register a Malena type with the framework.
Definition Export.h:38

When to use MLExport vs ML_EXPORT

Scenario Use
Registration in a header file ML_EXPORT — uses inline struct, ODR-safe
Registration in a .cpp file Either — MLExport or ML_EXPORT both work
Prefer no macros MLExport + explicit instantiation

How registration works

Forcing instantiation of MLExport<T> causes Registrar's constructor to run exactly once before main(). For Fireable types it calls Fireable::_register with a new singleton instance. For non-Fireable non-Plugin types a static_assert fires at compile time. Plugin extern "C" symbols are handled by the ML_EXPORT macro's plugin block — MLExport does not emit them, so plugins must use ML_EXPORT.

Template Parameters
TThe type to register. Must derive from ml::Fireable. For ml::Plugin types use ML_EXPORT instead.
See also
ML_EXPORT, ml::Fireable

Definition at line 73 of file MLExport.h.


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