libzypp: zyppng::Transition< Source, ev, Target, Cond, Op > Struct Template Reference

libzypp 17.38.8

zyppng::Transition< Source, ev, Target, Cond, Op > Struct Template Reference

`#include <zypp-core/ng/base/statemachine.h>`

## Public Types
using | SourceType = Source
using | TargetType = Target

## Public Member Functions
template<typename Statemachine>
std::shared_ptr< Target > | operator() (Statemachine &sm, Source &oldState)
bool | checkCondition (Source &currentState)
SignalProxy< void() > | eventSource (Source *st)
auto | eventAccessor () const

## Detailed Description

template<typename Source, detail::EventSource< Source > ev, typename Target, auto Cond = DefaultStateCondition, auto Op = DefaultStateTransition>
struct zyppng::Transition< Source, ev, Target, Cond, Op >

Defines a transition between Source and Target states. The EventSource ev triggers the transition from Source to Target if the condition Cond evaluates to true. The operation Op is called between exiting the old and entering the new state. It can be used to transfer information from the old into the new state.

Template Parameters

  Source | defines the type of the Source state
  ev | takes a member function pointer returning the event trigger signal that is used to trigger the transition to Target
  Target | defines the type of the Target state
  Cond | Defines the transition condition, can be used if the same event could trigger different transitions based on a condition, this can also be set to a simple boolean true or false
  Op | defines the transition operation from Source to Target states, this is either a function with the signature: std::unique_ptr<Target> ( Statemachine &, Source & ) or it can be a member function pointer of Source with the signature: std::unique_ptr<Target> ( Source::* ) ( )

Note
  While it would be possible to implement the statemachine to operate only on non pointer types for the states , I chose to use std::unique_ptr<State> instead to make the handling of States with signals less error prone. Because even move assigning a signal that has connected lambda slots which have captured the this pointer will break the code. While it could be worked around to connect and disconnect signals in the enter() and exit() functions not doing so would crash the code. Leaving that note here in case we want to change that behaviour in the future.

Definition at line 237 of file statemachine.h.

## Member Typedef Documentation

## ◆ SourceType

template<typename Source, detail::EventSource< Source > ev, typename Target, auto Cond = DefaultStateCondition, auto Op = DefaultStateTransition>

using zyppng::Transition< Source, ev, Target, Cond, Op >::SourceType = Source

Definition at line 239 of file statemachine.h.

## ◆ TargetType

template<typename Source, detail::EventSource< Source > ev, typename Target, auto Cond = DefaultStateCondition, auto Op = DefaultStateTransition>

using zyppng::Transition< Source, ev, Target, Cond, Op >::TargetType = Target

Definition at line 240 of file statemachine.h.

## Member Function Documentation

## ◆ operator()()

template<typename Source, detail::EventSource< Source > ev, typename Target, auto Cond = DefaultStateCondition, auto Op = DefaultStateTransition>
template<typename Statemachine>

std::shared_ptr< Target > zyppng::Transition< Source, ev, Target, Cond, Op >::operator() | ( | Statemachine & | sm,
|  | Source & | oldState )
| inline

Definition at line 244 of file statemachine.h.

## ◆ checkCondition()

template<typename Source, detail::EventSource< Source > ev, typename Target, auto Cond = DefaultStateCondition, auto Op = DefaultStateTransition>

bool zyppng::Transition< Source, ev, Target, Cond, Op >::checkCondition | ( | Source & | currentState | ) |
| inline

Definition at line 256 of file statemachine.h.

## ◆ eventSource()

template<typename Source, detail::EventSource< Source > ev, typename Target, auto Cond = DefaultStateCondition, auto Op = DefaultStateTransition>

SignalProxy< void() > zyppng::Transition< Source, ev, Target, Cond, Op >::eventSource | ( | Source * | st | ) |
| inline

Definition at line 267 of file statemachine.h.

## ◆ eventAccessor()

template<typename Source, detail::EventSource< Source > ev, typename Target, auto Cond = DefaultStateCondition, auto Op = DefaultStateTransition>

auto zyppng::Transition< Source, ev, Target, Cond, Op >::eventAccessor | ( |  | ) | const
| inline

Definition at line 271 of file statemachine.h.

The documentation for this struct was generated from the following file:

- zypp-core/ng/base/statemachine.h