P-E-R-R-Y
Utilitaires, contrats et vendors du moteur, en une seule doc
Loading...
Searching...
No Matches
modulemanager
Collaboration diagram for modulemanager:

Classes

class  IModuleManager
 La meme table que ModuleManager, mais dont les DEUX axes sont des chaines connues seulement au chargement. More...
class  ModuleManager< Ts >
 A Stride<SharedLibrary, Ts...> : a loaded dll IS a row, a contract (Ts...) IS a column, a module is the cell where they meet. More...
class  SharedLibrary
 Encapsule le handle d'une bibliotheque dynamique. Rien de plus. More...
class  Stride< Identity, Columns >
 A two-axis table : rows are a dense index (0,1,2... reused, like ecs Entity), columns are Columns... (fixed, known at compile time, one vector<optional<T>> per type — no hashing). Each row also carries an Identity, whatever the caller wants a row to own or be keyed by — a SharedLibrary, a string, anything. Stride does not know or care what Identity is. More...

Detailed Description

modulemanager

version: 1.0.0

Finds, loads and keeps track of modules at runtime.

Split out of imodule: that repo holds the interface a module answers to, this one holds the machinery that loads them. An interface and a manager are two different jobs.

What is in here

  • ModuleManager — the table of loaded modules. One row per shared library, one column per contract.
  • SharedLibrary — a dlopen/dlsym wrapper, RAII, cross-platform.
  • Stride — the two-axis table ModuleManager is built on. Generic: rows carry an identity, columns carry optional values.

Loading

A loaded library IS a row, a contract IS a column, a module is the cell where they meet. Two identifiers, one per axis :

  • the key you passed to Load() names a row,
  • the static type T names a column.

Both are yours. The manager never reads IModule::name() or type() — a module's address is its position in the table, not something it declares about itself. Those two stay on the module for whoever needs them, typically a plugin host that has no static types to work with.

modules.Load("./raylib_impl.dylib", "ray");
modules.Load("./sfml_impl.dylib", "sfml");
modules.Get<IGraphic2Module>("ray"); // the cell : contract + key
modules.Get<IGraphic3Module>("sfml"); // nullptr, sfml has no 3D
modules.GetAll<IGraphic2Module>(); // every library providing it
modules.GetAll("ray"); // everything "ray" provides
modules.Unload("ray"); // clears the row, closes the dll
A vendor's 2D factory : window, input, loaded resources and the objects that reference them....
Definition IGraphic2Module.hpp:37
A vendor's 3D factory. Extends IGraphic2Module : implementing it means implementing all of the 2D too...
Definition IGraphic3Module.hpp:36
A Stride<SharedLibrary, Ts...> : a loaded dll IS a row, a contract (Ts...) IS a column,...
Definition ModuleManager.hpp:52
T * Get(const std::string &key)
The T module of the library named by this key, or nullptr.
Definition ModuleManager.hpp:121
bool Load(const std::string &path, const std::string &key)
Opens the dll, adds its row, fills the columns it provides.
Definition ModuleManager.hpp:72
std::vector< T * > GetAll()
Every library providing T.
Definition ModuleManager.hpp:157
void Unload(const std::string &key)
Clears this row's columns AND its identity, which closes the dll. One call, nothing left to tidy up.
Definition ModuleManager.hpp:89

Partial coverage is not an error : a vendor that only does 2D simply leaves the 3D column empty, and Get returns nullptr.

Find(key) hands back the row itself, so Get<T>(entity) and Get(entity) can work on it without looking the key up again.