MUSX Document Model
Loading...
Searching...
No Matches
musx::dom::Base Class Reference

Base class to enforce polymorphism across all DOM classes. More...

#include <BaseClasses.h>

+ Inheritance diagram for musx::dom::Base:

Public Types

enum class  ShareMode { All , Partial , None }
 Describes how this instance is shared between part and score. More...
 
using SharedNodes = std::set< std::string >
 The container type for shared nodes.
 

Public Member Functions

virtual ~Base () noexcept(false)=default
 Virtual destructor for polymorphic behavior.
 
DocumentPtr getDocument () const
 Gets a reference to the Document.
 
Cmper getSourcePartId () const
 Gets the source partId for this instance. If an instance is fully shared with the score, the source is SCORE_PARTID. If an instance is partially shared or non shared, the source is the ID of the part that sourced it.
 
ShareMode getShareMode () const
 Gets the sharing mode for this instance.
 
const SharedNodesgetUnlinkedNodes () const
 Gets the unlinked nodes for this instance. (Only populated for ShareMode::Partial)
 
void addUnlinkedNode (const std::string &nodeName)
 Adds a shared node for this instance.
 
virtual void integrityCheck (const std::shared_ptr< Base > &ptrToThis)
 Allows a class to determine if it has been properly contructed by the factory and fix issues that it can, such as creating default instances of contained classes.
 
virtual bool requireAllFields () const
 Specifies if the parser should alert (print or throw) when an unknown xml tag is found for this class.
 

Protected Member Functions

 Base (const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode)
 Constructs the base class.
 
 Base (const Base &)=default
 explicit default copy constructor
 
 Base (Base &&) noexcept=default
 explicit default move constructor
 
Baseoperator= (const Base &)
 no-op copy assignment operator allows subclasses to copy their values.
 
Baseoperator= (Base &&) noexcept
 no-op move assignment operator allows subclasses to move their values.
 

Detailed Description

Base class to enforce polymorphism across all DOM classes.

Member Enumeration Documentation

◆ ShareMode

enum class musx::dom::Base::ShareMode
strong

Describes how this instance is shared between part and score.

Enumerator
All 

All parts and score always share (no "share" attribute). Default.

Partial 

Part and score share some attributes and have their own unlinked versions of others. (attribute "share"="true")

None 

Each part and score has its own version of the DOM class. (attribute "share"="false")

Constructor & Destructor Documentation

◆ Base()

musx::dom::Base::Base ( const DocumentWeakPtr document,
Cmper  partId,
ShareMode  shareMode 
)
inlineprotected

Constructs the base class.

Parameters
documentA weak pointer to the parent document
partIdThe part ID for this instance, or zero if for score.
shareModeThe ShareMode for this instance.

Member Function Documentation

◆ getDocument()

DocumentPtr musx::dom::Base::getDocument ( ) const
inline

Gets a reference to the Document.

Returns
A pointer to the Document instance.

◆ getSourcePartId()

Cmper musx::dom::Base::getSourcePartId ( ) const
inline

Gets the source partId for this instance. If an instance is fully shared with the score, the source is SCORE_PARTID. If an instance is partially shared or non shared, the source is the ID of the part that sourced it.

Warning
This value is often different than the value used to retrieve the instance. Normally you should not use it to retrieve another instance.

◆ integrityCheck()

virtual void musx::dom::Base::integrityCheck ( const std::shared_ptr< Base > &  ptrToThis)
inlinevirtual

Allows a class to determine if it has been properly contructed by the factory and fix issues that it can, such as creating default instances of contained classes.

The default implementation should always be called inside an overridden implementation.

Parameters
ptrToThisThis instance in a shared_ptr. (Avoids need for shared_from_this.)
Exceptions
musx::dom::integrity_errorif there is a problem.

Reimplemented in musx::dom::OthersArray< ElementType, REQUIRED_SIZE >, musx::dom::OthersArray< int >, musx::dom::OthersArray< int, 7 >, musx::dom::OthersArray< int16_t >, musx::dom::OthersArray< StaffCmper >, musx::dom::OthersArray< unsigned, 7 >, musx::dom::OthersArray< unsigned, 8 >, musx::dom::DetailsArray< ElementType, REQUIRED_SIZE >, musx::dom::DetailsArray< int, 7 >, musx::dom::KeySignature, musx::dom::details::GFrameHold, musx::dom::details::IndependentStaffDetails, musx::dom::details::KeySymbolListElement, musx::dom::details::SecondaryBeamBreak, musx::dom::details::StaffGroup, musx::dom::Entry, musx::dom::options::LyricOptions, musx::dom::options::TextOptions::InsertSymbolInfo, musx::dom::others::BeatChartElement, musx::dom::others::Frame, musx::dom::others::Measure, musx::dom::others::MeasureExprAssign, musx::dom::others::MultimeasureRest, musx::dom::others::MultiStaffInstrumentGroup, musx::dom::others::PageTextAssign, musx::dom::others::RepeatEndingStart, musx::dom::others::StaffSystem, musx::dom::others::SmartShape::TerminationSeg, musx::dom::others::SmartShape, musx::dom::others::SmartShapeCustomLine, musx::dom::details::CenterShape, musx::dom::others::Staff, musx::dom::others::StaffStyle, and musx::dom::others::StaffStyleAssign.

◆ requireAllFields()

virtual bool musx::dom::Base::requireAllFields ( ) const
inlinevirtual

Specifies if the parser should alert (print or throw) when an unknown xml tag is found for this class.

Some classes make it difficult to discover all the possible xml tags that might be used for all its options. An example is others::TextBlock. By overriding this function, a class can allow its members to be discovered as needed without causing error messages or throwing exceptions.

Remarks
This value only escapes errors on fields. Enum values must still have all values provided to avoid error messages or exceptions.

Reimplemented in musx::dom::details::TieAlterBase, musx::dom::Note, musx::dom::Entry, musx::dom::others::ArticulationDef, musx::dom::others::Measure, musx::dom::others::MeasureExprAssign, musx::dom::others::PartDefinition, musx::dom::others::ShapeExpressionDef, musx::dom::others::TextBlock, musx::dom::others::Staff, and musx::dom::others::StaffStyle::Masks.