CuteHMI - Services (CuteHMI.Services.3)
cutehmi::services::SelfService Class Reference

Self service. More...

#include <cutehmi/services/SelfService.hpp>

Inheritance diagram for cutehmi::services::SelfService:
cutehmi::services::AbstractService QQmlParserStatus cutehmi::services::Serviceable QObject CuteHMI::Services::SelfService

Signals

void startingStateChanged ()
 
void activeStateChanged ()
 
void stoppingStateChanged ()
 
void brokenStateChanged ()
 
void repairingStateChanged ()
 
void evacuatingStateChanged ()
 
void signalToStartedChanged ()
 
void signalToStoppedChanged ()
 
void signalToBrokenChanged ()
 
void signalToIdlingChanged ()
 
void signalToYieldingChanged ()
 
- Signals inherited from cutehmi::services::AbstractService
void stopTimeoutChanged ()
 
void startTimeoutChanged ()
 
void repairTimeoutChanged ()
 
void shutdownTimeoutChanged ()
 
void nameChanged ()
 
void statusChanged ()
 
void started ()
 
void stopped ()
 
void activated ()
 
void initialized ()
 This signal is emitted, when service has performed all the initialization tasks and it is ready to be started. More...
 

Public Member Functions

 SelfService (QObject *parent=nullptr)
 
 ~SelfService () override
 
QAbstractStatestartingState () const
 
void setStartingState (QAbstractState *startingState)
 
QAbstractStateactiveState () const
 
void setActiveState (QAbstractState *activeState)
 
QAbstractStatestoppingState () const
 
void setStoppingState (QAbstractState *stoppingState)
 
QAbstractStaterepairingState () const
 
void setBrokenState (QAbstractState *brokenState)
 
QAbstractStatebrokenState () const
 
void setRepairingState (QAbstractState *repairingState)
 
QAbstractStateevacuatingState () const
 
void setEvacuatingState (QAbstractState *evacuatingState)
 
QJSValue signalToStarted () const
 
void setSignalToStarted (const QJSValue &signal)
 
QJSValue signalToStopped () const
 
void setSignalToStopped (const QJSValue &signal)
 
QJSValue signalToBroken () const
 
void setSignalToBroken (const QJSValue &signal)
 
QJSValue signalToIdling () const
 
void setSignalToIdling (const QJSValue &signal)
 
QJSValue signalToYielding () const
 
void setSignalToYielding (const QJSValue &signal)
 
void configureStarting (QState *starting, AssignStatusFunction assignStatus) override
 Configure starting state. More...
 
void configureStarted (QState *active, const QState *idling, const QState *yielding, AssignStatusFunction assignStatus) override
 Configure started state. More...
 
void configureStopping (QState *stopping, AssignStatusFunction assignStatus) override
 Configure stopping state. More...
 
void configureBroken (QState *broken, AssignStatusFunction assignStatus) override
 Configure broken state. More...
 
void configureRepairing (QState *repairing, AssignStatusFunction assignStatus) override
 Configure repairing state. More...
 
void configureEvacuating (QState *evacuating, AssignStatusFunction assignStatus) override
 Configure evacuating state. More...
 
std::unique_ptr< QAbstractTransitiontransitionToStarted () const override
 Transition to started state. More...
 
std::unique_ptr< QAbstractTransitiontransitionToStopped () const override
 Transition to stopped state. More...
 
std::unique_ptr< QAbstractTransitiontransitionToBroken () const override
 Transition to broken state. More...
 
std::unique_ptr< QAbstractTransitiontransitionToYielding () const override
 Transition to yielding state. More...
 
std::unique_ptr< QAbstractTransitiontransitionToIdling () const override
 Transition to idling state. More...
 
void classBegin () override
 
void componentComplete () override
 
- Public Member Functions inherited from cutehmi::services::AbstractService
 ~AbstractService () override
 
int shutdownTimeout () const
 
void setShutdownTimeout (int shutdownTimeout)
 Set shutdown timeout. More...
 
int stopTimeout () const
 
void setStopTimeout (int stopTimeout)
 Set stop timeout. More...
 
int startTimeout () const
 
void setStartTimeout (int startTimeout)
 Set start timeout. More...
 
int repairTimeout () const
 
void setRepairTimeout (int repairTimeout)
 Set repair timeout. More...
 
QString name () const
 
void setName (const QString &name)
 
QString status () const
 
cutehmi::services::StateInterfacestates () const
 Get state interface. More...
 
QQmlListProperty< cutehmi::services::AbstractServiceControllerdefaultControllerList ()
 
QQmlListProperty< cutehmi::services::AbstractServiceControllercontrollerList ()
 
Q_INVOKABLE void appendController (cutehmi::services::AbstractServiceController *controller)
 
Q_INVOKABLE void clearControllers ()
 
- Public Member Functions inherited from QObject
virtual const QMetaObjectmetaObject () const const
 
 QObject (QObject *parent)
 
virtual ~QObject ()
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
bool signalsBlocked () const const
 
bool blockSignals (bool block)
 
QThreadthread () const const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
const QObjectListchildren () const const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectInfo () const const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const const
 
QList< QByteArraydynamicPropertyNames () const const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
bool inherits (const char *className) const const
 
void deleteLater ()
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
 Q_CLASSINFO (Name, Value)
 
 Q_INTERFACES (...)
 
 Q_PROPERTY (...)
 
 Q_ENUMS (...)
 
 Q_FLAGS (...)
 
 Q_ENUM (...)
 
 Q_FLAG (...)
 
 Q_ENUM_NS (...)
 
 Q_FLAG_NS (...)
 
 Q_OBJECT Q_OBJECT
 
 Q_GADGET Q_GADGET
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SLOTS Q_SLOTS
 
 Q_SLOT Q_SLOT
 
 Q_EMIT Q_EMIT
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
virtual void classBegin ()=0
 
virtual void componentComplete ()=0
 
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...
 

Static Public Member Functions

static cutehmi::services::SelfServiceAttachedTypeqmlAttachedProperties (QObject *object)
 
- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 

Properties

QAbstractStatestartingState
 
QAbstractStateactiveState
 
QAbstractStatestoppingState
 
QAbstractStatebrokenState
 
QAbstractStaterepairingState
 
QAbstractStateevacuatingState
 
QJSValue signalToStarted
 
QJSValue signalToStopped
 
QJSValue signalToBroken
 
QJSValue signalToIdling
 
QJSValue signalToYielding
 
- Properties inherited from cutehmi::services::AbstractService
int shutdownTimeout
 
int stopTimeout
 
int startTimeout
 
int repairTimeout
 
QString name
 
QString status
 
cutehmi::services::StateInterfacestates
 
QQmlListProperty< cutehmi::services::AbstractServiceControllerdefaultControllers
 
QQmlListProperty< cutehmi::services::AbstractServiceControllercontrollers
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Public Types inherited from cutehmi::services::Serviceable
typedef std::function< void(QState &state, const QString &status)> AssignStatusFunction
 
- Public Slots inherited from cutehmi::services::AbstractService
void start ()
 
void stop ()
 
void activate ()
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Static Public Attributes inherited from cutehmi::services::AbstractService
static constexpr int INITIAL_SHUTDOWN_TIMEOUT = 180000
 
static constexpr int INITIAL_STOP_TIMEOUT = 30000
 
static constexpr int INITIAL_START_TIMEOUT = 30000
 
static constexpr int INITIAL_REPAIR_TIMEOUT = 30000
 
static constexpr const char * INITIAL_NAME = "Unnamed Service"
 
- Protected Types inherited from cutehmi::services::AbstractService
typedef QList< AbstractServiceController * > ControllersContainer
 
- Protected Slots inherited from cutehmi::services::AbstractService
void setStatus (const QString &status)
 
- Protected Member Functions inherited from cutehmi::services::AbstractService
 AbstractService (StateInterface *stateInterface, const QString &status, QObject *parent=nullptr, const ControllersContainer *defaultControllers=&DefaultControllers())
 Constructor. More...
 
const ControllersContainercontrollers () const
 
ControllersContainercontrollers ()
 
- Protected Member Functions inherited from QObject
QObjectsender () const const
 
int senderSignalIndex () const const
 
int receivers (const char *signal) const const
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
- Protected Member Functions inherited from cutehmi::services::Serviceable
 Serviceable ()=default
 
virtual ~Serviceable ()=default
 
 Serviceable (const Serviceable &other)=default
 
Serviceableoperator= (const Serviceable &other)=default
 
- Static Protected Member Functions inherited from cutehmi::services::AbstractService
static const ControllersContainerDefaultControllers ()
 

Detailed Description

Self service.

Self service is a service which implements Serviceable interface by itself and allows one to customize a bahavior through a bunch of properties. This allows services to be defined within QML, as QML component must be a descendant of QObject and implementing Serviceable in QML directly is not possible. For C++ classes it's typically more flexible and straightforward to implement Serviceable interface and use Service as QML component which controls the serviceable object.

Constructor & Destructor Documentation

◆ SelfService()

cutehmi::services::SelfService::SelfService ( QObject parent = nullptr)
explicit

◆ ~SelfService()

cutehmi::services::SelfService::~SelfService ( )
override

Member Function Documentation

◆ activeState()

QAbstractState * cutehmi::services::SelfService::activeState ( ) const

◆ activeStateChanged

void cutehmi::services::SelfService::activeStateChanged ( )
signal

◆ brokenState()

QAbstractState * cutehmi::services::SelfService::brokenState ( ) const

◆ brokenStateChanged

void cutehmi::services::SelfService::brokenStateChanged ( )
signal

◆ classBegin()

void cutehmi::services::SelfService::classBegin ( )
overridevirtual

Implements QQmlParserStatus.

◆ componentComplete()

void cutehmi::services::SelfService::componentComplete ( )
overridevirtual

Implements QQmlParserStatus.

◆ configureBroken()

void cutehmi::services::SelfService::configureBroken ( QState broken,
AssignStatusFunction  assignStatus 
)
overridevirtual

Configure broken state.

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

Implements cutehmi::services::Serviceable.

◆ configureEvacuating()

void cutehmi::services::SelfService::configureEvacuating ( QState evacuating,
AssignStatusFunction  assignStatus 
)
overridevirtual

Configure evacuating state.

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

Implements cutehmi::services::Serviceable.

◆ configureRepairing()

void cutehmi::services::SelfService::configureRepairing ( QState repairing,
AssignStatusFunction  assignStatus 
)
overridevirtual

Configure repairing state.

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

Implements cutehmi::services::Serviceable.

◆ configureStarted()

void cutehmi::services::SelfService::configureStarted ( QState active,
const QState idling,
const QState yielding,
AssignStatusFunction  assignStatus 
)
overridevirtual

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.

Implements cutehmi::services::Serviceable.

◆ configureStarting()

void cutehmi::services::SelfService::configureStarting ( QState starting,
AssignStatusFunction  assignStatus 
)
overridevirtual

Configure starting state.

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

Implements cutehmi::services::Serviceable.

◆ configureStopping()

void cutehmi::services::SelfService::configureStopping ( QState stopping,
AssignStatusFunction  assignStatus 
)
overridevirtual

Configure stopping state.

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

Implements cutehmi::services::Serviceable.

◆ evacuatingState()

QAbstractState * cutehmi::services::SelfService::evacuatingState ( ) const

◆ evacuatingStateChanged

void cutehmi::services::SelfService::evacuatingStateChanged ( )
signal

◆ qmlAttachedProperties()

SelfServiceAttachedType * cutehmi::services::SelfService::qmlAttachedProperties ( QObject object)
static

◆ repairingState()

QAbstractState * cutehmi::services::SelfService::repairingState ( ) const

◆ repairingStateChanged

void cutehmi::services::SelfService::repairingStateChanged ( )
signal

◆ setActiveState()

void cutehmi::services::SelfService::setActiveState ( QAbstractState activeState)

◆ setBrokenState()

void cutehmi::services::SelfService::setBrokenState ( QAbstractState brokenState)

◆ setEvacuatingState()

void cutehmi::services::SelfService::setEvacuatingState ( QAbstractState evacuatingState)

◆ setRepairingState()

void cutehmi::services::SelfService::setRepairingState ( QAbstractState repairingState)

◆ setSignalToBroken()

void cutehmi::services::SelfService::setSignalToBroken ( const QJSValue signal)

◆ setSignalToIdling()

void cutehmi::services::SelfService::setSignalToIdling ( const QJSValue signal)

◆ setSignalToStarted()

void cutehmi::services::SelfService::setSignalToStarted ( const QJSValue signal)

◆ setSignalToStopped()

void cutehmi::services::SelfService::setSignalToStopped ( const QJSValue signal)

◆ setSignalToYielding()

void cutehmi::services::SelfService::setSignalToYielding ( const QJSValue signal)

◆ setStartingState()

void cutehmi::services::SelfService::setStartingState ( QAbstractState startingState)

◆ setStoppingState()

void cutehmi::services::SelfService::setStoppingState ( QAbstractState stoppingState)

◆ signalToBroken()

QJSValue cutehmi::services::SelfService::signalToBroken ( ) const

◆ signalToBrokenChanged

void cutehmi::services::SelfService::signalToBrokenChanged ( )
signal

◆ signalToIdling()

QJSValue cutehmi::services::SelfService::signalToIdling ( ) const

◆ signalToIdlingChanged

void cutehmi::services::SelfService::signalToIdlingChanged ( )
signal

◆ signalToStarted()

QJSValue cutehmi::services::SelfService::signalToStarted ( ) const

◆ signalToStartedChanged

void cutehmi::services::SelfService::signalToStartedChanged ( )
signal

◆ signalToStopped()

QJSValue cutehmi::services::SelfService::signalToStopped ( ) const

◆ signalToStoppedChanged

void cutehmi::services::SelfService::signalToStoppedChanged ( )
signal

◆ signalToYielding()

QJSValue cutehmi::services::SelfService::signalToYielding ( ) const

◆ signalToYieldingChanged

void cutehmi::services::SelfService::signalToYieldingChanged ( )
signal

◆ startingState()

QAbstractState * cutehmi::services::SelfService::startingState ( ) const

◆ startingStateChanged

void cutehmi::services::SelfService::startingStateChanged ( )
signal

◆ stoppingState()

QAbstractState * cutehmi::services::SelfService::stoppingState ( ) const

◆ stoppingStateChanged

void cutehmi::services::SelfService::stoppingStateChanged ( )
signal

◆ transitionToBroken()

std::unique_ptr< QAbstractTransition > cutehmi::services::SelfService::transitionToBroken ( ) const
overridevirtual

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.

Implements cutehmi::services::Serviceable.

◆ transitionToIdling()

std::unique_ptr< QAbstractTransition > cutehmi::services::SelfService::transitionToIdling ( ) const
overridevirtual

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.

Implements cutehmi::services::Serviceable.

◆ transitionToStarted()

std::unique_ptr< QAbstractTransition > cutehmi::services::SelfService::transitionToStarted ( ) const
overridevirtual

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.

Implements cutehmi::services::Serviceable.

◆ transitionToStopped()

std::unique_ptr< QAbstractTransition > cutehmi::services::SelfService::transitionToStopped ( ) const
overridevirtual

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.

Implements cutehmi::services::Serviceable.

◆ transitionToYielding()

std::unique_ptr< QAbstractTransition > cutehmi::services::SelfService::transitionToYielding ( ) const
overridevirtual

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.

Implements cutehmi::services::Serviceable.

Property Documentation

◆ activeState

QAbstractState * cutehmi::services::SelfService::activeState
readwrite

◆ brokenState

QAbstractState * cutehmi::services::SelfService::brokenState
readwrite

◆ evacuatingState

QAbstractState * cutehmi::services::SelfService::evacuatingState
readwrite

◆ repairingState

QAbstractState * cutehmi::services::SelfService::repairingState
readwrite

◆ signalToBroken

QJSValue cutehmi::services::SelfService::signalToBroken
readwrite

◆ signalToIdling

QJSValue cutehmi::services::SelfService::signalToIdling
readwrite

◆ signalToStarted

QJSValue cutehmi::services::SelfService::signalToStarted
readwrite

◆ signalToStopped

QJSValue cutehmi::services::SelfService::signalToStopped
readwrite

◆ signalToYielding

QJSValue cutehmi::services::SelfService::signalToYielding
readwrite

◆ startingState

QAbstractState * cutehmi::services::SelfService::startingState
readwrite

◆ stoppingState

QAbstractState * cutehmi::services::SelfService::stoppingState
readwrite