MUSX Document Model
Loading...
Searching...
No Matches
musx::factory::TextsFactory Class Reference

Factory class for creating Texts objects from XML. More...

#include <PoolFactory.h>

+ Inheritance diagram for musx::factory::TextsFactory:

Static Public Member Functions

static auto extractFromXml (const XmlElementPtr &element, const dom::DocumentPtr &document, ElementLinker &elementLinker, const TextsPoolPtr &pool)
 Extracts a TextsBase object from an XML element.
 
static std::shared_ptr< PoolType > create (const XmlElementPtr &element, const dom::DocumentPtr &document, ElementLinker &elementLinker)
 Creates a OthersPool object from an XML element.
 
- Static Public Member Functions inherited from musx::factory::PoolFactory< TextsFactory, dom::TextsBase, dom::TextsPool >
static std::shared_ptr< dom::TextsPoolcreate (const XmlElementPtr &element, const dom::DocumentPtr &document, ElementLinker &elementLinker)
 Creates a OthersPool object from an XML element.
 

Additional Inherited Members

- Static Protected Member Functions inherited from musx::factory::FactoryBase
template<typename DataType , typename ParserFunc >
static void getFieldFromXml (const XmlElementPtr &element, const std::string &nodeName, DataType &dataField, ParserFunc parserFunc, bool expected=false)
 Helper function to check if a child exists and populate it if so.
 
static XmlElementPtr getFirstChildElement (const XmlElementPtr &element, const std::string &childElementName)
 Helper function to throw when child element does not exist.
 
static std::optional< std::string > getOptionalChildText (const XmlElementPtr &element, const std::string &childElementName)
 Helper function to return std::nullopt when child element does not exist.
 
template<typename T >
static std::optional< T > getOptionalChildTextAs (const XmlElementPtr &element, const std::string &childElementName, T defaultValue={})
 Helper function to return std::nullopt when child element does not exist.
 

Detailed Description

Factory class for creating Texts objects from XML.

This class specializes PoolFactory to handle the creation of Texts objects, representing various attributes stored in an TextsPool. It includes an XML parsing mechanism to extract and create these objects, which are used in the document model.

Member Function Documentation

◆ create()

static std::shared_ptr< PoolType > musx::factory::PoolFactory< DerivedType, ObjectBase, PoolType >::create ( const XmlElementPtr element,
const dom::DocumentPtr document,
ElementLinker elementLinker 
)
inlinestatic

Creates a OthersPool object from an XML element.

This function creates an object pool by parsing the XML element representing the <others> node. It iterates over each child element of the XML element, extracts relevant information using DerivedType::extractFromXml, and adds the created objects to the pool.

Parameters
elementThe XML element representing the <others> node.
documentThe document object providing context for the XML parsing.
elementLinkerA class for storing deferred linkage commands.
Returns
A fully populated ObjectPoolType object.

◆ extractFromXml()

static auto musx::factory::TextsFactory::extractFromXml ( const XmlElementPtr element,
const dom::DocumentPtr document,
ElementLinker elementLinker,
const TextsPoolPtr pool 
)
inlinestatic

Extracts a TextsBase object from an XML element.

Extracts a TextsBase derived object from the given XML element using the specified attributes such as number or type. Throws an exception if a required attribute is missing.

Parameters
elementThe XML element from which to extract the object.
documentThe document object providing context for the XML parsing.
elementLinkerThe ElementLinker instance that is used to resolve all internal connections after the document is created.
poolThe pool we are constructiong. (It hasn't been assigned to document yet.)
Returns
A shared pointer to the created object.
Exceptions
std::invalid_argumentif required attributes are missing.