TuringSim
C++ framework to simulate abstract computing models
Public Types | Public Member Functions | List of all members
TuringSim::Transition::Transition< StateType_, StorageType_, ApplyHelperType_ > Class Template Referenceabstract

Base class for transitions. More...

#include <transition/transition.h>

Public Types

typedef StateType_ StateType
 The type of states.
 
typedef StorageType_ StorageType
 The type of storage.
 
typedef ApplyHelperType_ ApplyHelperType
 The type of apply helpers.
 

Public Member Functions

 Transition ()=default
 The default constructor.
 
 Transition (const Transition &)=default
 The default copy constructor.
 
 Transition (Transition &&)=default
 The default move constructor.
 
Transitionoperator= (const Transition &)=default
 The default copy assignment operator. More...
 
Transitionoperator= (Transition &&)=default
 The default move assignment operator. More...
 
virtual ~Transition ()=default
 The default virtual destructor.
 
virtual std::optional< ApplyHelperTypematch (const StateType &state, const StorageType &storage) const =0
 Test whether the transition matches a configuration. Returned optional is empty iff the transition does not match. More...
 
virtual StateType apply (const StateType &state, StorageType &storage, ApplyHelperType &&helper, bool &running) const =0
 Apply a previously matching transition and return the new state. More...
 

Detailed Description

template<typename StateType_, typename StorageType_, typename ApplyHelperType_>
class TuringSim::Transition::Transition< StateType_, StorageType_, ApplyHelperType_ >

Base class for transitions.

Template Parameters
StateType_Type of states.
StorageType_Type of storage.
ApplyHelperType_Type used to forward information from match to apply.

Definition at line 67 of file transition.h.

Member Function Documentation

◆ apply()

template<typename StateType_ , typename StorageType_ , typename ApplyHelperType_ >
virtual StateType TuringSim::Transition::Transition< StateType_, StorageType_, ApplyHelperType_ >::apply ( const StateType state,
StorageType storage,
ApplyHelperType &&  helper,
bool &  running 
) const
pure virtual

Apply a previously matching transition and return the new state.

Parameters
[in]statethe pre-state.
[in,out]storagethe storage, modified in place.
[in]helperthe helper, returned by Transition::match(const StateType& state, const StorageType& storage) const.
[in,out]runningwhether the machine is still running. If false, the same state is returned, and running is not updated. If true, the transition is applied, and running may be changed if the transition stop the machine.
Returns
The new state.
Exceptions
ConfigurationDoesNotMatchExceptionif the transition does not match, optionally.

If we try to apply a transition that does not match, the behavior is undefined.

Implemented in TuringSim::Transition::Amnesic::AmnesicMachineTransition< StateType_ >.

◆ match()

template<typename StateType_ , typename StorageType_ , typename ApplyHelperType_ >
virtual std::optional<ApplyHelperType> TuringSim::Transition::Transition< StateType_, StorageType_, ApplyHelperType_ >::match ( const StateType state,
const StorageType storage 
) const
pure virtual

◆ operator=() [1/2]

template<typename StateType_ , typename StorageType_ , typename ApplyHelperType_ >
Transition& TuringSim::Transition::Transition< StateType_, StorageType_, ApplyHelperType_ >::operator= ( const Transition< StateType_, StorageType_, ApplyHelperType_ > &  )
default

The default copy assignment operator.

Returns
a reference to *this.

◆ operator=() [2/2]

template<typename StateType_ , typename StorageType_ , typename ApplyHelperType_ >
Transition& TuringSim::Transition::Transition< StateType_, StorageType_, ApplyHelperType_ >::operator= ( Transition< StateType_, StorageType_, ApplyHelperType_ > &&  )
default

The default move assignment operator.

Returns
a reference to *this.

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