P-E-R-R-Y
Utilitaires, contrats et vendors du moteur, en une seule doc
Loading...
Searching...
No Matches
ModuleManager< Ts > Class Template Reference

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...

#include <ModuleManager.hpp>

Inheritance diagram for ModuleManager< Ts >:
Collaboration diagram for ModuleManager< Ts >:

Public Member Functions

bool Load (const std::string &path, const std::string &key)
 Opens the dll, adds its row, fills the columns it provides.
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.
std::optional< Entity > Find (const std::string &key) const
 The row named by this key, or nothing.
template<typename T>
T * Get (const std::string &key)
 The T module of the library named by this key, or nullptr.
template<typename T>
T * Get (Entity e)
 The T module of this exact row, or nullptr.
SharedLibrary * Get (Entity e)
 The SharedLibrary of this exact row, or nullptr.
template<typename T>
std::vector< T * > GetAll ()
 Every library providing T.
std::vector< IModule * > GetAllByKey (const std::string &key) override
 Every module the library named by this key provides.
std::vector< IModule * > GetAll () override
 Every module of every loaded library.
IModule * Get (const std::string &type, const std::string &key) override
 La case, par deux chaines. Impose par IModuleRegistry.
IModule * Current (const std::string &type) override
 Le module en service pour ce contrat, ou nullptr.
void Select (const std::string &type, IModule *module) override
 L'hote declare son choix. Un seul par contrat.
std::vector< IModule * > GetAllByType (const std::string &type) override
 La ligne, par chaine. Impose par IModuleRegistry.

Detailed Description

template<std::derived_from< IModule >... Ts>
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.

Two identifiers, one per axis, and nothing else :

  • 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 identity is its position in the table, not something it declares about itself. IModule is only required so GetAllByKey(key) has a common base to hand a whole row back through.

ModuleManager<IGraphicModule, IWindowModule> modules;

modules.Load("./ray.so", "ray");
modules.Get<IGraphicModule>("ray"); // one, by contract and key
modules.GetAll<IGraphicModule>();   // every library providing it
modules.GetAllByKey("ray");              // everything "ray" provides
modules.Get<IGraphicModule>(e);     // one, by row
modules.Get(e);                     // the SharedLibrary of this row
modules.Unload("ray");              // clears the row, closes the dll

Member Function Documentation

◆ Current()

template<std::derived_from< IModule >... Ts>
IModule * ModuleManager< Ts >::Current ( const std::string & type)
inlineoverride

Le module en service pour ce contrat, ou nullptr.

◆ Find()

template<std::derived_from< IModule >... Ts>
std::optional< Entity > ModuleManager< Ts >::Find ( const std::string & key) const
inline

The row named by this key, or nothing.

Parameters
key
Returns
std::optional<Entity>

◆ Get() [1/4]

template<std::derived_from< IModule >... Ts>
template<typename T>
T * ModuleManager< Ts >::Get ( const std::string & key)
inline

The T module of the library named by this key, or nullptr.

nullptr covers both "no such key" and "this library does not provide T" — neither is an error.

Template Parameters
T
Parameters
key
Returns
T*

◆ Get() [2/4]

template<std::derived_from< IModule >... Ts>
IModule * ModuleManager< Ts >::Get ( const std::string & type,
const std::string & key )
inlineoverride

La case, par deux chaines. Impose par IModuleRegistry.

SEUL endroit ou ce manager lit type(). Il ne s'en sert jamais pour son propre rangement - ses colonnes sont des types statiques. Il ne le lit que pour repondre a une question posee en chaines, par quelqu'un qui n'a pas les types sous la main.

O(colonnes) au lieu de O(1) : la voie rapide de ce manager reste Get<T>(cle).

Parameters
type
key
Returns
IModule*

◆ Get() [3/4]

template<std::derived_from< IModule >... Ts>
SharedLibrary * ModuleManager< Ts >::Get ( Entity e)
inline

The SharedLibrary of this exact row, or nullptr.

Parameters
e
Returns
SharedLibrary*

◆ Get() [4/4]

template<std::derived_from< IModule >... Ts>
template<typename T>
T * ModuleManager< Ts >::Get ( Entity e)
inline

The T module of this exact row, or nullptr.

Template Parameters
T
Parameters
e
Returns
T*

◆ GetAll() [1/2]

template<std::derived_from< IModule >... Ts>
template<typename T>
std::vector< T * > ModuleManager< Ts >::GetAll ( )
inline

Every library providing T.

Template Parameters
T
Returns
std::vector<T *>

◆ GetAll() [2/2]

template<std::derived_from< IModule >... Ts>
std::vector< IModule * > ModuleManager< Ts >::GetAll ( )
inlineoverride

Every module of every loaded library.

The list you hand to something compiled apart - a game in a dll - which cannot name a contract by template parameter. It sorts them out with IModule::type() and name().

Returns
std::vector<IModule *>

◆ GetAllByKey()

template<std::derived_from< IModule >... Ts>
std::vector< IModule * > ModuleManager< Ts >::GetAllByKey ( const std::string & key)
inlineoverride

Every module the library named by this key provides.

Type-erased : you get the cells of that row without naming their columns. Useful to list what a library offers ; to actually use one, Get<T>(key) hands it back with its real type.

Parameters
key
Returns
std::vector<IModule *>

◆ GetAllByType()

template<std::derived_from< IModule >... Ts>
std::vector< IModule * > ModuleManager< Ts >::GetAllByType ( const std::string & type)
inlineoverride

La ligne, par chaine. Impose par IModuleRegistry.

Parameters
type
Returns
std::vector<IModule *>

◆ Load()

template<std::derived_from< IModule >... Ts>
bool ModuleManager< Ts >::Load ( const std::string & path,
const std::string & key )
inline

Opens the dll, adds its row, fills the columns it provides.

A key already in use is refused, so a row is never ambiguous.

Parameters
path
key
Returns
bool

◆ Select()

template<std::derived_from< IModule >... Ts>
void ModuleManager< Ts >::Select ( const std::string & type,
IModule * module )
inlineoverride

L'hote declare son choix. Un seul par contrat.

◆ Unload()

template<std::derived_from< IModule >... Ts>
void ModuleManager< Ts >::Unload ( const std::string & key)
inline

Clears this row's columns AND its identity, which closes the dll. One call, nothing left to tidy up.

Parameters
key

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