MUSX Document Model
Loading...
Searching...
No Matches
musx::factory::TypeRegistry< Types > Class Template Reference

A registry of types for mapping XML node names to types. More...

#include <TypeRegistry.h>

Static Public Member Functions

template<typename PoolPtr , typename... Args>
static std::shared_ptr< BasecreateInstance (const PoolPtr &pool, const XmlElementPtr &node, ElementLinker &elementLinker, const DocumentPtr &document, Args &&... args)
 Creates an instance of the registered type corresponding to the provided node name.
 

Detailed Description

template<typename... Types>
class musx::factory::TypeRegistry< Types >

A registry of types for mapping XML node names to types.

This template struct provides a mechanism to map XML node names to their corresponding types and supports instantiation of types based on these names.

Template Parameters
TypesThe list of types to be registered.

Member Function Documentation

◆ createInstance()

template<typename... Types>
template<typename PoolPtr , typename... Args>
static std::shared_ptr< Base > musx::factory::TypeRegistry< Types >::createInstance ( const PoolPtr &  pool,
const XmlElementPtr node,
ElementLinker elementLinker,
const DocumentPtr document,
Args &&...  args 
)
inlinestatic

Creates an instance of the registered type corresponding to the provided node name.

Uses the node name to look up the registered type and create an instance of it.

Template Parameters
PoolPtrThe object pool type for getting score versions (when doing part linkage)
ArgsThe argument types required by the constructor of the target type.
Parameters
poolThe object pool for getting score versions (when doing part linkage)
nodeThe XML node from which an instance is to be created.
elementLinkerThe ElementLinker instance that is used to resolve all internal connections after the document is created.
documentThe document that we are creating the instance for.
argsArguments to be forwarded to the constructor of the target type.
Returns
A shared pointer to the created instance of the base type, or nullptr if not found.