8 #ifndef __DIADES__AUTOMATA__EXPERIMENTAL__FINITEAUTOMATON__HH__ 9 #define __DIADES__AUTOMATA__EXPERIMENTAL__FINITEAUTOMATON__HH__ 11 #include<unordered_set> 20 namespace Experimental
44 template<
typename _StatePropertyId,
45 typename _InputSymbolId,
46 typename _NullStatePropertyId = NullValue<_StatePropertyId>,
47 typename _NullInputSymbolId = NullValue< _InputSymbolId>>
103 if(
this != &automaton)
145 const vector<InputSymbolId> &
271 std::pair<AcceptingStateIterator, bool>
337 template<
typename FA,
typename BS>
345 auto it = std::find_if(bs.begin(), bs.end(),
348 return source.isAcceptingState(s);
352 target.setAcceptingState(s);
367 template<
typename S,
typename I,
typename NS,
typename NI>
398 virtual std::pair<State, bool>
422 template<
typename S,
typename I,
typename NS,
typename NI,
typename StatePropertyCombination>
424 public ManagedStateCreation< FiniteAutomaton<S, I, NS, NI>, typename StatePropertyCombination::StateProperty>,
448 MSC(source, target, sourceStateManager, targetStateManager),
BSSSC()
461 virtual std::pair<State, bool>
470 auto statePropertyId = MSC::targetStateManager().statePropertyId(
471 StatePropertyCombination()(MSC::sourceStateManager().getStateProperty(MSC::_source.
getStatePropertyId(source)),
474 auto result = MSC::_target.newState(statePropertyId);
492 template<
typename S,
typename I,
typename NS,
typename NI>
522 virtual std::pair<State, bool>
529 auto result = std::make_pair(SC::_target.
newState(),
true);
550 template<
typename S,
typename I,
typename NS,
typename NI,
typename StatePropertyCombination>
552 public ManagedStateCreation<FiniteAutomaton<S, I, NS, NI>, typename StatePropertyCombination::Property>,
576 MSC(source, target, sourceStateManager, targetStateManager),
BSBSC()
589 virtual std::pair<State, bool>
597 auto statePropertyId = MSC::targetStateManager().statePropertyId(
598 StatePropertyCombination()(begin, end));
600 auto result = MSC::_target.newState(statePropertyId);
645 template <
typename S,
typename I,
typename NS,
typename NI,
646 typename _StateProperty,
typename StatePropertyCombination>
672 :
MSSC(machines, managers, syncManager)
689 bool isNotAcceptor =
false;
691 while(!isNotAcceptor && (index != states.size()))
693 isNotAcceptor = !MSSC::_machines->at(index)->isAcceptingState(states[index]);
698 MSSC::_target->setAcceptingState(newState);
711 virtual std::pair<typename MSSC::State, bool>
715 auto result = MSSC::newState(states);
716 if(std::get<1>(result))
740 template <
typename S,
typename I,
typename NS,
typename NI>
769 virtual std::pair<typename SC::State, bool>
777 SC::target().setInitial(result.first);
781 SC::target().setAcceptingState(result.first);
794 virtual std::pair<typename SC::State, bool>
797 auto result = SC::target().newState(statePropertyId);
800 SC::target().setInitial(result.first);
804 SC::target().setAcceptingState(result.first);
828 template<
typename S,
typename I,
typename NS,
typename NI,
typename StateProperty>
843 MSC(source, target, sourceStateManager, targetStateManager)
860 virtual std::pair<State, bool>
863 auto propId = MSC::source().getStatePropertyId(source);
864 std::pair<State, bool> result;
867 if(MSC::sourceStateManager().hasStatePropertyId(propId))
869 result = MSC::target().newState(MSC::targetStateManager().statePropertyId(MSC::sourceStateManager().getStateProperty(propId)));
873 result = MSC::target().newState(propId);
882 MSC::target().setInitial(result.first);
886 MSC::target().setAcceptingState(result.first);
905 virtual std::pair<State, bool>
908 auto result = MSC::target().newState(statePropertyId);
911 auto propId = MSC::source().getStatePropertyId(source);
914 if(MSC::sourceStateManager().hasStatePropertyId(propId))
916 MSC::targetStateManager().setStateProperty(MSC::sourceStateManager().getStateProperty(propId),
924 MSC::target().setInitial(result.first);
928 MSC::target().setAcceptingState(result.first);
typename MSC::StateProperty StateProperty
EventPropertyIdIterator eventEnd() const
typename AcceptingStates::const_iterator ConstAcceptingStateIterator
State initialState() const
typename MSC::StatePropertyId StatePropertyId
virtual std::pair< State, bool > newState(State source, const FsmBs &bs)
InputSymbolIdIterator inputSymbolIdEnd() const
decltype(auto) numberOfInputSymbolIds() const
unsigned numberOfInitialStates() const
virtual std::pair< State, bool > newState(State source)
virtual std::pair< State, bool > newState(const FsmBs &bs)
typename AcceptingStates::iterator AcceptingStateIterator
vector< EventPropertyId >::const_iterator EventPropertyIdIterator
Diades::Graph::Edge Transition
typename MSC::StateProperty StateProperty
StateMachine & operator=(const StateMachine &machine)
typename MSC::StatePropertyId StatePropertyId
ConstAcceptingStateIterator acceptingStateBegin() const
StatePropertyIdRangeIterator< StateIterator > statePropertyIdRangeIterator(StateIterator iterator) const
FaultyEventStateMachine< CandidateId, EventInfoId > Fsm
_NullStatePropertyId NullStatePropertyId
typename StateMachine::State State
typename MSC::StManager StManager
const AcceptingStates & acceptingStates() const
ConstAcceptingStateIterator acceptingStateEnd() const
const StatePropertyId nullStatePropertyId
typename Fsm::StatePropertyId StatePropertyId
Diades::Graph::Node State
MakeAcceptingState(const FA &source, FA &target, const BS &bs, State s)
InitialStateIterator initialStateEnd() const
void setAcceptingState(const std::vector< typename MSSC::State > &states, typename MSSC::State newState)
_StatePropertyId StatePropertyId
FiniteAutomaton & operator=(const FiniteAutomaton &automaton)
typename BSSSC::FsmBs FsmBs
const vector< InputSymbolId > & inputSymbolIds() const
typename MSC::State State
virtual void insertEventPropertyId(const EventPropertyId &event)
AcceptingStates _accepting
virtual std::pair< State, bool > newState(const FsmBs &bs)
_InputSymbolId InputSymbolId
typename SM::Transition Transition
OnlyStateCreator(const FA &source, FA &target)
typename BSBSC::FsmBs FsmBs
void clearAllAcceptingStates()
const vector< EventPropertyId > & events() const
std::pair< AcceptingStateIterator, bool > setAcceptingState(State state)
virtual void deleteState(State state)
virtual void deleteState(State state)
delete state
Namespace of the Diades project.
typename MSC::State State
OnlySourceStateCreator(const FA &source, FA &target)
virtual std::pair< typename MSSC::State, bool > newState(const std::vector< typename MSSC::State > &states)
virtual std::pair< typename SC::State, bool > newState(typename SC::State source)
Graph::Graph & behaviour()
typename BSBSC::FsmBs FsmBs
EventPropertyIdIterator eventBegin() const
virtual std::pair< State, bool > newState(State source, const FsmBs &bs)
InitialStateIterator initialStateBegin() const
typename MSC::StatePropertyId StatePropertyId
typename Fsm::State State
virtual std::pair< State, bool > newState(State source, const StatePropertyId &statePropertyId)
std::unordered_set< State > AcceptingStates
virtual bool isValid() const
StateCopy(const FA &source, FA &target)
FiniteAutomaton(const FiniteAutomaton &automaton)
InputSymbolIdIterator inputSymbolIdBegin() const
typename SM::EventPropertyIdIterator InputSymbolIdIterator
ManagedBeliefStateBasedStateCreator(const FA &source, FA &target, const StatePropertyManager< StateProperty, StatePropertyId > &sourceStateManager, StatePropertyManager< StateProperty, StatePropertyId > &targetStateManager)
void insertInputSymbolId(InputSymbolId symbol)
const StatePropertyId & getStatePropertyId(State state) const
_NullInputSymbolId NullInputSymbolId
typename BSSSC::FsmBs FsmBs
virtual std::pair< typename SC::State, bool > newState(typename SC::State source, const typename SC::StatePropertyId &statePropertyId)
bool isAcceptingState(State s) const
_StateProperty StateProperty
ManagedStateCopy(const Fsm &source, Fsm &target, const StManager &sourceStateManager, StManager &targetStateManager)
typename MSC::State State
ManagedBeliefStateWithSourceStateCreator(const FA &source, FA &target, const StatePropertyManager< StateProperty, StatePropertyId > &sourceStateManager, StatePropertyManager< StateProperty, StatePropertyId > &targetStateManager)
decltype(auto) numberOfAcceptingStates() const
AcceptingStateIterator unsetAcceptingState(State state)
typename SC::StatePropertyId StatePropertyId
ManagedSynchronisedAcceptingStateCreation(const std::vector< typename Ptr< typename MSSC::StateMachine >::ConstP > &machines, const std::vector< typename Ptr< typename MSSC::SManager >::ConstP > &managers, typename MSSC::SManager &syncManager)
bool isInitial(State state) const
void swapAcceptingState(State state)
swap the status of the state as accepting/non-accepting
unsigned numberOfEvents() const