xentara-workbench-plugin v1.0.1
The Xentara Workbench Plugin Framework
Loading...
Searching...
No Matches
xentara::workbench::bindings::PropertyContainer Class Referenceabstract

Base class for objects that contain properties, directly or indirectly. More...

#include <xentara/workbench/bindings/PropertyContainer.hpp>

+ Inheritance diagram for xentara::workbench::bindings::PropertyContainer:

Classes

class  ErrorCountSubscription
 
struct  ForEachCrossReferenceOptions
 Options for forEachCrossReference() More...
 
struct  SetEnclosingPropertyContainerOptions
 Options for setEnclosingPropertyContainer() and resetEnclosingPropertyContainer() More...
 
struct  SubPropertyContainerListChangedOptions
 Options for subPropertyContainerListChanged() and related functions. More...
 

Public Member Functions

 PropertyContainer () noexcept=default
 Default constructor.
 
 PropertyContainer (const PropertyContainer &other)
 Copy constructor.
 
 PropertyContainer (PropertyContainer &&other) noexcept
 Move constructor.
 
auto operator= (const PropertyContainer &rhs) -> PropertyContainer &
 Copy assignment operator.
 
auto operator= (PropertyContainer &&rhs) noexcept -> PropertyContainer &
 Move assignment operator that does not actually assign anything.
 
virtual ~PropertyContainer ()=0
 Virtual destructor.
 
auto setEnclosingPropertyContainer (PropertyContainer &enclosingContainer, SetEnclosingPropertyContainerOptions options={}) -> void
 Sets the enclosing container.
 
auto resetEnclosingPropertyContainer (SetEnclosingPropertyContainerOptions options={}) -> void
 Resets the enclosing container.
 
auto enclosingPropertyContainer () const -> PropertyContainer *
 Gets the enclosing container.
 
auto propertyErrorCount () const -> std::size_t
 Gets the number of error properties, including those of sub containers.
 
template<std::invocable Callback>
auto subscribeToPropertyErrorCount (Callback &&callback) -> ErrorCountSubscription
 Subscribes to a property.
 
auto forEachCrossReference (const ForEachCrossReferenceFunction &function, ForEachCrossReferenceOptions options={}) noexcept -> void
 Calls a function for each cross reference contained within the container.
 

Protected Member Functions

auto subPropertyContainerAdded (const PropertyContainer &container) -> void
 Must be called by derived classes if a sub container was added.
 
auto subPropertyContainerRemoved (const PropertyContainer &container) -> void
 Must be called by derived classes if a sub container was removed.
 
auto subPropertyContainerListChanged (SubPropertyContainerListChangedOptions options={}) -> void
 Must be called by derived classes if the list of sub containers changed completely.
 
auto subPropertyContainerListCopied (const PropertyContainer &other, SubPropertyContainerListChangedOptions options={}) -> void
 Must be called by derived classes if the list of sub containers was copied from another container.
 
auto subPropertyContainerListMoved (PropertyContainer &other, SubPropertyContainerListChangedOptions options={}) -> void
 Must be called by derived classes if the list of sub containers was moved from another container.
 
auto subPropertyContainerListSwapped (PropertyContainer &other, SubPropertyContainerListChangedOptions options={}) -> void
 Must be called by derived classes if the list of sub containers was swapped with another container.
 
auto localPropertyErrorCountChanged () -> void
 Must be called by derived classes if the value returned by localPropertyErrorCount() has changed.
 
auto raisePropertyNotification (const PropertyId &propertyId) const -> void
 Passes a property notification to the enclosing container.
 

Private Member Functions

virtual auto propertyErrorCountChanged () -> void
 Called by the framework if the property error count changed.
 
virtual auto forEachSubPropertyContainer (const ForEachSubPropertyContainerFunction &function, bool includeInvisible) noexcept -> void=0
 Called by the framework to iterate over all the sub containers.
 
virtual auto forEachLocalCrossReference (const ForEachCrossReferenceFunction &function, bool includeInvisible) noexcept -> void=0
 Called by the framework to iterate over all the sub containers.
 
virtual auto localPropertyErrorCount () const -> std::size_t=0
 Called by the framework to get the number of error properties of this container, excluding those of sub containers.
 
virtual auto propertyNotificationRaised (const PropertyId &propertyId) -> void=0
 Called by the framework if a sub container raised a property notification.
 

Detailed Description

Base class for objects that contain properties, directly or indirectly.

Property containers form a hierarchy, where an enclosing containers can contain one or more sub containers. This is used to enclose [sub elements](skill::SubElement] in their parent elements, for example.

Constructor & Destructor Documentation

◆ PropertyContainer() [1/3]

xentara::workbench::bindings::PropertyContainer::PropertyContainer ( )
defaultnoexcept

Default constructor.

◆ PropertyContainer() [2/3]

xentara::workbench::bindings::PropertyContainer::PropertyContainer ( const PropertyContainer other)

Copy constructor.

This constructor does not copy the reference to the enclosing container. The new container will not have an enclosing container.

Since this constructor does not know how to copy the list of sub containers, the new container will not have any sub containers. If a derived implementation copies the sub containers, it must correctly set their enclosing containers to this container, and then call subPropertyContainerListCopied().

Parameters
otherThe container that is to be copied

◆ PropertyContainer() [3/3]

xentara::workbench::bindings::PropertyContainer::PropertyContainer ( PropertyContainer &&  other)
noexcept

Move constructor.

This constructor does not move the reference to the enclosing container. The new container will not have an enclosing container.

Since this constructor does not know how to move the list of sub containers, the new container will not have any sub containers. If a derived implementation moves the sub containers, it must correctly set their enclosing containers to this container, and then call subPropertyContainerListMoved().

Please note that subPropertyContainerListMoved() is not noexcept, and thus a derived implementation that calls that function cannot be noexcept either. subPropertyContainerListMoved() cannot be noexcept because it may have to call callbacks that may raise exceptions.

Parameters
otherThe container that is to be moved

◆ ~PropertyContainer()

xentara::workbench::bindings::PropertyContainer::~PropertyContainer ( )
pure virtualdefault

Virtual destructor.

Member Function Documentation

◆ enclosingPropertyContainer()

auto xentara::workbench::bindings::PropertyContainer::enclosingPropertyContainer ( ) const -> PropertyContainer *

Gets the enclosing container.

Returns
The enclosing container, or nullptr if none is set.

◆ forEachCrossReference()

auto xentara::workbench::bindings::PropertyContainer::forEachCrossReference ( const ForEachCrossReferenceFunction function,
ForEachCrossReferenceOptions  options = {} 
) -> void
noexcept

Calls a function for each cross reference contained within the container.

◆ forEachLocalCrossReference()

virtual auto xentara::workbench::bindings::PropertyContainer::forEachLocalCrossReference ( const ForEachCrossReferenceFunction function,
bool  includeInvisible 
) -> void
privatepure virtualnoexcept

Called by the framework to iterate over all the sub containers.

Parameters
functionA function that must be called for each sub container.
includeInvisibleWhether to include invisible cross references.

Implemented in xentara::workbench::skill::SubElementVector< Element, Allocator >, and xentara::workbench::bindings::PropertyController.

◆ forEachSubPropertyContainer()

virtual auto xentara::workbench::bindings::PropertyContainer::forEachSubPropertyContainer ( const ForEachSubPropertyContainerFunction function,
bool  includeInvisible 
) -> void
privatepure virtualnoexcept

Called by the framework to iterate over all the sub containers.

Parameters
functionA function that must be called for each sub container.
includeInvisibleWhether to include invisible containers.

Implemented in xentara::workbench::skill::SubElementVector< Element, Allocator >, and xentara::workbench::bindings::PropertyController.

◆ localPropertyErrorCount()

virtual auto xentara::workbench::bindings::PropertyContainer::localPropertyErrorCount ( ) const -> std::size_t
privatepure virtual

Called by the framework to get the number of error properties of this container, excluding those of sub containers.

Returns
This function must return the property count of this container only, without the error count of the children.

Implemented in xentara::workbench::bindings::PropertyController, and xentara::workbench::skill::SubElementVector< Element, Allocator >.

◆ localPropertyErrorCountChanged()

auto xentara::workbench::bindings::PropertyContainer::localPropertyErrorCountChanged ( ) -> void
protected

Must be called by derived classes if the value returned by localPropertyErrorCount() has changed.

This function will automatically notify any enclosing containers, and also cause the propertyErrorCountChanged() callback to be called.

◆ operator=() [1/2]

auto xentara::workbench::bindings::PropertyContainer::operator= ( const PropertyContainer rhs) -> PropertyContainer &

Copy assignment operator.

This assignment operator does not change the reference to the enclosing container.

Since this assignment operator does not know how to copy the list of sub containers, the sub containers will not be modified. If a derived implementation copies the sub containers, it must correctly set their enclosing containers to this container, and then call subPropertyContainerListCopied().

Parameters
rhsThe container that is to be copied
Returns
A reference to this object

◆ operator=() [2/2]

auto xentara::workbench::bindings::PropertyContainer::operator= ( PropertyContainer &&  rhs) -> PropertyContainer &
noexcept

Move assignment operator that does not actually assign anything.

This assignment operator does not change the reference to the enclosing container.

Since this assignment operator does not know how to move the list of sub containers, the sub containers will not be modified. If a derived implementation moves the sub containers, it must correctly set their enclosing containers to this container, and then call subPropertyContainerListMoved().

Please note that subPropertyContainerListMoved() is not noexcept, and thus a derived implementation that calls that function cannot be noexcept either. subPropertyContainerListMoved() cannot be noexcept because it may have to call callbacks that may raise exceptions.

Parameters
rhsThe container that is to be moved
Returns
A reference to this object

◆ propertyErrorCount()

auto xentara::workbench::bindings::PropertyContainer::propertyErrorCount ( ) const -> std::size_t

Gets the number of error properties, including those of sub containers.

Returns
The total property count of this container and all its sub containers

◆ propertyErrorCountChanged()

virtual auto xentara::workbench::bindings::PropertyContainer::propertyErrorCountChanged ( ) -> void
privatevirtual

Called by the framework if the property error count changed.

This function is a lightweight way for a property container to react to react to changes in the property error count. It is equivalent to subscribing to the property error count using subscribeToPropertyErrorCount().

Default Implementation
The default implementation does nothing.

◆ propertyNotificationRaised()

virtual auto xentara::workbench::bindings::PropertyContainer::propertyNotificationRaised ( const PropertyId propertyId) -> void
privatepure virtual

Called by the framework if a sub container raised a property notification.

propertyId The ID of the property that was raised.

Implemented in xentara::workbench::skill::SubElementVector< Element, Allocator >, and xentara::workbench::bindings::PropertyController.

◆ raisePropertyNotification()

auto xentara::workbench::bindings::PropertyContainer::raisePropertyNotification ( const PropertyId propertyId) const -> void
protected

Passes a property notification to the enclosing container.

Parameters
propertyIdThe ID of the property to raise. This ID should normally be name-based property ID created using the literal operator operator""_propertyId(), rather than an address-based property ID, so that it is independent of any property controller.

◆ resetEnclosingPropertyContainer()

auto xentara::workbench::bindings::PropertyContainer::resetEnclosingPropertyContainer ( SetEnclosingPropertyContainerOptions  options = {}) -> void

Resets the enclosing container.

Note
You do not have to call this function yourself. It is called automatically when a container is removed from a collection like skill::SubElementVector.
Parameters
optionsOptions for suppressing notifications.

◆ setEnclosingPropertyContainer()

auto xentara::workbench::bindings::PropertyContainer::setEnclosingPropertyContainer ( PropertyContainer enclosingContainer,
SetEnclosingPropertyContainerOptions  options = {} 
) -> void

Sets the enclosing container.

Note
You do not have to call this function yourself. It is called automatically when properties are configured inside PropertyController::configureProperties(), or when a container is added to a collection like skill::SubElementVector.
Parameters
enclosingContainerThe new enclosing container.
optionsOptions for suppressing notifications.

◆ subPropertyContainerAdded()

auto xentara::workbench::bindings::PropertyContainer::subPropertyContainerAdded ( const PropertyContainer container) -> void
protected

Must be called by derived classes if a sub container was added.

◆ subPropertyContainerListChanged()

auto xentara::workbench::bindings::PropertyContainer::subPropertyContainerListChanged ( SubPropertyContainerListChangedOptions  options = {}) -> void
protected

Must be called by derived classes if the list of sub containers changed completely.

◆ subPropertyContainerListCopied()

auto xentara::workbench::bindings::PropertyContainer::subPropertyContainerListCopied ( const PropertyContainer other,
SubPropertyContainerListChangedOptions  options = {} 
) -> void
protected

Must be called by derived classes if the list of sub containers was copied from another container.

This function is mainly intended to be called from copy constructors and copy assignment operators after the sub containers have been copied and properly initialized.

This function guards against self-assignment, so passing *this as this parameter is safe, and will result in a no-op.

The container from which the sub containers have been copied. It is safe to pass *this as this parameter.

◆ subPropertyContainerListMoved()

auto xentara::workbench::bindings::PropertyContainer::subPropertyContainerListMoved ( PropertyContainer other,
SubPropertyContainerListChangedOptions  options = {} 
) -> void
protected

Must be called by derived classes if the list of sub containers was moved from another container.

This function is mainly intended to be called from move constructors and move assignment operators after the sub containers have been moved and properly updated.

This function guards against self-assignment, so passing *this as this parameter is safe, and will result in a no-op.

The container from which the sub containers have been moved. It is safe to pass *this as this parameter.

◆ subPropertyContainerListSwapped()

auto xentara::workbench::bindings::PropertyContainer::subPropertyContainerListSwapped ( PropertyContainer other,
SubPropertyContainerListChangedOptions  options = {} 
) -> void
protected

Must be called by derived classes if the list of sub containers was swapped with another container.

This function is mainly intended to be called from swap functions after the sub containers have been swapped and properly updated.

This function guards against self-assignment, so passing *this as this parameter is safe, and will result in a no-op.

The container from which the sub containers have been moved. It is safe to pass *this as this parameter.

◆ subPropertyContainerRemoved()

auto xentara::workbench::bindings::PropertyContainer::subPropertyContainerRemoved ( const PropertyContainer container) -> void
protected

Must be called by derived classes if a sub container was removed.

◆ subscribeToPropertyErrorCount()

template<std::invocable Callback>
auto xentara::workbench::bindings::PropertyContainer::subscribeToPropertyErrorCount ( Callback &&  callback) -> ErrorCountSubscription

Subscribes to a property.

Parameters
callbackA callback that will be called whenever the peroperty error count changed.
Returns
An automatic object that can be used to unsubscribe the subscription.