CuteHMI - Services (CuteHMI.Services.3)
cutehmi::services::Serviceable Class Referenceabstract

Serviceable interface. More...

#include <cutehmi/services/Serviceable.hpp>

Inheritance diagram for cutehmi::services::Serviceable:
cutehmi::services::SelfService cutehmi::services::ServiceGroup CuteHMI::Services::SelfService CuteHMI::Services::ServiceGroup

Public Types

typedef std::function< void(QState &state, const QString &status)> AssignStatusFunction
 

Public Member Functions

virtual void configureStarting (QState *starting, AssignStatusFunction assignStatus)=0
 Configure starting state. More...
 
virtual void configureStarted (QState *active, const QState *idling, const QState *yielding, AssignStatusFunction assignStatus)=0
 Configure started state. More...
 
virtual void configureStopping (QState *stopping, AssignStatusFunction assignStatus)=0
 Configure stopping state. More...
 
virtual void configureBroken (QState *broken, AssignStatusFunction assignStatus)=0
 Configure broken state. More...
 
virtual void configureRepairing (QState *repairing, AssignStatusFunction assignStatus)=0
 Configure repairing state. More...
 
virtual void configureEvacuating (QState *evacuating, AssignStatusFunction assignStatus)=0
 Configure evacuating state. More...
 
virtual std::unique_ptr< QAbstractTransitiontransitionToStarted () const =0
 Transition to started state. More...
 
virtual std::unique_ptr< QAbstractTransitiontransitionToStopped () const =0
 Transition to stopped state. More...
 
virtual std::unique_ptr< QAbstractTransitiontransitionToBroken () const =0
 Transition to broken state. More...
 
virtual std::unique_ptr< QAbstractTransitiontransitionToYielding () const =0
 Transition to yielding state. More...
 
virtual std::unique_ptr< QAbstractTransitiontransitionToIdling () const =0
 Transition to idling state. More...
 

Protected Member Functions

 Serviceable ()=default
 
virtual ~Serviceable ()=default
 
 Serviceable (const Serviceable &other)=default
 
Serviceableoperator= (const Serviceable &other)=default
 

Detailed Description

Serviceable interface.

By implementing this interface object is allowed to be embedded inside Service instance.

Implementing Serviceable interface involves configuring states and defining transitions. During configuration state interface can be extended by adding additional child states to the states passed by configuration functions.

Standard states and transitions are shown on the following state chart diagram.

State interface

Implementing object can utilize the state machine according to its needs by:

  • defining when standard transitions take place (and likely trigger them)
  • adding custom states to the standard ones
  • connecting slots to QState signals (custom or standard ones)

Member Typedef Documentation

◆ AssignStatusFunction

Constructor & Destructor Documentation

◆ Serviceable() [1/2]

cutehmi::services::Serviceable::Serviceable ( )
protecteddefault

◆ ~Serviceable()

virtual cutehmi::services::Serviceable::~Serviceable ( )
protectedvirtualdefault

◆ Serviceable() [2/2]

cutehmi::services::Serviceable::Serviceable ( const Serviceable other)
protecteddefault

Member Function Documentation

◆ configureBroken()

virtual void cutehmi::services::Serviceable::configureBroken ( QState broken,
AssignStatusFunction  assignStatus 
)
pure virtual

Configure broken state.

Parameters
brokenstate.
assignStatusa function callback that allows one to associate the state with custom service status.

Implemented in cutehmi::services::SelfService, and cutehmi::services::ServiceGroup.

◆ configureEvacuating()

virtual void cutehmi::services::Serviceable::configureEvacuating ( QState evacuating,
AssignStatusFunction  assignStatus 
)
pure virtual

Configure evacuating state.

Parameters
evacuatingstate.
assignStatusa function callback that allows one to associate the state with custom service status.

Implemented in cutehmi::services::SelfService, and cutehmi::services::ServiceGroup.

◆ configureRepairing()

virtual void cutehmi::services::Serviceable::configureRepairing ( QState repairing,
AssignStatusFunction  assignStatus 
)
pure virtual

Configure repairing state.

Parameters
repairingstate.
assignStatusa function callback that allows one to associate the state with custom service status.

Implemented in cutehmi::services::SelfService, and cutehmi::services::ServiceGroup.

◆ configureStarted()

virtual void cutehmi::services::Serviceable::configureStarted ( QState active,
const QState idling,
const QState yielding,
AssignStatusFunction  assignStatus 
)
pure virtual

Configure started state.

Started state is not directly accessible. Intead its child states shall be configured.

Parameters
activeactive state. In this state any resource-hungry and intense operations shall be performed. Serviceable object may add child states to active state for its own use.
idlingidling state. In this state a serviceable should not perform any intense operations or consume resources. Serviceable decides by itself when to enter idling state. Some objects may never activate the transition to idling state. When serviceable object is ready to become active again it should signal it by activating transitionToIdling(). No child states can be added to idling state.
yieldingyielding state. In this state a service should not perform any intense operations or consume resources. It should just wait until it is activated, therefore no child states can be added to yielding state.
assignStatusa function callback that allows one to associate the state with custom service status.

Implemented in cutehmi::services::SelfService, and cutehmi::services::ServiceGroup.

◆ configureStarting()

virtual void cutehmi::services::Serviceable::configureStarting ( QState starting,
AssignStatusFunction  assignStatus 
)
pure virtual

Configure starting state.

Parameters
startingstate.
assignStatusa function callback that allows one to associate the state with custom service status.

Implemented in cutehmi::services::SelfService, and cutehmi::services::ServiceGroup.

◆ configureStopping()

virtual void cutehmi::services::Serviceable::configureStopping ( QState stopping,
AssignStatusFunction  assignStatus 
)
pure virtual

Configure stopping state.

Parameters
stoppingstate.
assignStatusa function callback that allows one to associate the state with custom service status.

Implemented in cutehmi::services::SelfService, and cutehmi::services::ServiceGroup.

◆ operator=()

Serviceable & cutehmi::services::Serviceable::operator= ( const Serviceable other)
protecteddefault

◆ transitionToBroken()

virtual std::unique_ptr< QAbstractTransition > cutehmi::services::Serviceable::transitionToBroken ( ) const
pure virtual

Transition to broken state.

Returns
transition to broken state. It is allowed to return nullptr. In such case service will never enter broken or repairing states.

Implemented in cutehmi::services::SelfService, and cutehmi::services::ServiceGroup.

◆ transitionToIdling()

virtual std::unique_ptr< QAbstractTransition > cutehmi::services::Serviceable::transitionToIdling ( ) const
pure virtual

Transition to idling state.

Returns
transition to idling state. It is allowed to return nullptr. In such case service will not enter idling state and will remain persistently active. This will make service impolite.

Implemented in cutehmi::services::SelfService, and cutehmi::services::ServiceGroup.

◆ transitionToStarted()

virtual std::unique_ptr< QAbstractTransition > cutehmi::services::Serviceable::transitionToStarted ( ) const
pure virtual

Transition to started state.

Returns
transition to started state. It is allowed to return nullptr. In such case transition from starting to started state will be immediate.

Implemented in cutehmi::services::SelfService, and cutehmi::services::ServiceGroup.

◆ transitionToStopped()

virtual std::unique_ptr< QAbstractTransition > cutehmi::services::Serviceable::transitionToStopped ( ) const
pure virtual

Transition to stopped state.

Returns
transition to stopped state. It is allowed to return nullptr. In such case transition from stopping to stopped state will be immediate.

Implemented in cutehmi::services::SelfService, and cutehmi::services::ServiceGroup.

◆ transitionToYielding()

virtual std::unique_ptr< QAbstractTransition > cutehmi::services::Serviceable::transitionToYielding ( ) const
pure virtual

Transition to yielding state.

Returns
transition to yielding state. It is allowed to return nullptr. In such case service will skip yielding state and immediately become active. This will make service impolite.

Implemented in cutehmi::services::SelfService, and cutehmi::services::ServiceGroup.