9 #ifndef __DIADES__AUTOMATA__EXPERIMENTAL__STATECREATION__HH 10 #define __DIADES__AUTOMATA__EXPERIMENTAL__STATECREATION__HH 21 namespace Experimental {
32 template<
typename _StateMachine>
38 return "Automata::StateCreation";
42 using Fsm = _StateMachine;
61 _source(source), _target(target) {
103 template<
typename StateMachine>
128 virtual std::pair<typename SC::State, bool>
130 return SC::_target->newState();
148 template<
typename StateMachine>
174 virtual std::pair<typename SC::State, bool>
176 auto result = SC::target().newState(SC::source().getStatePropertyId(source));
177 if (SC::source().isInitial(source)) {
178 SC::target().setInitial(result.first);
191 virtual std::pair<typename SC::State, bool>
193 auto result = SC::target().newState(statePropertyId);
194 if (SC::source().isInitial(source)) {
195 SC::target().setInitial(result.first);
209 template<
typename StateMachine,
typename _StateProperty>
229 return _sourceStateManager;
238 return _targetStateManager;
256 _sourceStateManager(sourceStateManager),
257 _targetStateManager(targetStateManager) {
262 template<
typename StateMachine,
typename StateProperty>
277 MSC(source, target, sourceStateManager, targetStateManager) {
288 virtual std::pair<State, bool>
290 auto propId = MSC::source().getStatePropertyId(source);
291 std::pair<State, bool> result;
292 if (propId != MSC::source().nullStatePropertyId) {
293 if (MSC::sourceStateManager().hasStatePropertyId(propId)) {
294 result = MSC::target().newState(MSC::targetStateManager().statePropertyId(MSC::sourceStateManager().getStateProperty(propId)));
296 result = MSC::target().newState(propId);
299 result = MSC::target().newState(MSC::source().nullStatePropertyId);
301 if (MSC::source().isInitial(source)) {
302 MSC::target().setInitial(result.first);
315 virtual std::pair<State, bool>
317 auto propId = MSC::source().getStatePropertyId(source);
318 std::pair<State, bool> result;
319 if (propId != MSC::source().nullStatePropertyId) {
321 if (MSC::sourceStateManager().hasStatePropertyId(propId)) {
322 const auto &
property = MSC::sourceStateManager().getStateProperty(propId);
323 if (!MSC::sourceStateManager().isNull(property)) {
327 if (!MSC::targetStateManager().hasStateProperty(property)) {
329 if (MSC::targetStateManager().setStateProperty(property, statePropertyId)) {
332 result = MSC::target().newState(statePropertyId);
338 "newState (ManagedStateCopy): attempting to create a state associated with a StatePropertyId already assigned to a StateProperty that is not the StateProperty of the source state");
344 result = MSC::target().newState(MSC::targetStateManager().statePropertyId(property));
352 result = std::pair(MSC::target().newState(),
true);
361 result = std::pair(MSC::target().newState(),
true);
366 result = std::pair(MSC::target().newState(),
true);
368 if (MSC::source().isInitial(source)) {
369 MSC::target().setInitial(result.first);
384 template<
typename StateMachine>
404 virtual std::pair<State, bool>
416 template<
typename StateMachine>
436 virtual std::pair<State, bool>
437 newState(
const FsmBs & bs) = 0;
450 template<
typename StateMachine>
477 virtual std::pair<State, bool>
483 return SC::_target.newState(SC::_source.getStatePropertyId(source));
498 template<
typename StateMachine,
typename StatePropertyCombination>
520 MSC(source, target, sourceStateManager, targetStateManager),
BSSSC() {
532 virtual std::pair<State, bool>
536 auto begin = MSC::sourceStateManager().infoIdRangeInfoIterator(MSC::_source.statePropertyIdRangeIterator(bs.
begin()));
538 auto end = MSC::sourceStateManager().infoIdRangeInfoIterator(MSC::_source.statePropertyIdRangeIterator(bs.
end()));
540 auto statePropertyId = MSC::targetStateManager().statePropertyId(
541 StatePropertyCombination()(MSC::sourceStateManager().getStateProperty(MSC::_source.getStatePropertyId(source)),
544 return MSC::_target.newState(statePropertyId);
560 template<
typename StateMachine>
587 virtual std::pair<State, bool>
593 return std::make_pair(SC::_target.newState(),
true);
607 template<
typename StateMachine,
typename StatePropertyCombination>
631 MSC(source, target, sourceStateManager, targetStateManager),
BSBSC() {
643 virtual std::pair<State, bool>
646 auto begin = MSC::sourceStateManager().infoIdRangeInfoIterator(MSC::_source.statePropertyIdRangeIterator(bs.
begin()));
648 auto end = MSC::sourceStateManager().infoIdRangeInfoIterator(MSC::_source.statePropertyIdRangeIterator(bs.
end()));
650 auto statePropertyId = MSC::targetStateManager().statePropertyId(
651 StatePropertyCombination()(begin, end));
653 return MSC::_target.newState(statePropertyId);
661 template<
typename T1,
typename T2>
670 template<
typename T1>
715 template<
typename _StateMachine,
typename _StateProperty,
typename StatePropertyCombination>
871 virtual std::pair<State, bool>
876 if (_target ==
nullptr) {
877 return std::pair<State, bool>(
State(),
false);
904 auto statePropertyId = _syncManager->statePropertyId(StatePropertyCombination()(begin, end));
909 return _target->newState(statePropertyId);
StateCopy(const StateMachine &source, StateMachine &target)
ManagedBeliefStateWithSourceStateCreator(const StateMachine &source, StateMachine &target, const StatePropertyManager< StateProperty, StatePropertyId > &sourceStateManager, StatePropertyManager< StateProperty, StatePropertyId > &targetStateManager)
const StManager & sourceStateManager() const
static ConstP get(const T &obj)
#define always_require(Exception, expr, message)
Ptr< StateMachine >::P _target
virtual std::pair< State, bool > newState(State source)
typename MSC::StateProperty StateProperty
virtual std::pair< State, bool > newState(State source, const FsmBs &bs)
FaultyEventStateMachine< CandidateId, EventInfoId > Fsm
StManager & targetStateManager()
const Fsm & source() const
typename StateMachine::State State
virtual std::pair< State, bool > newState(const FsmBs &bs)
typename Fsm::StatePropertyId StatePropertyId
Diades::Graph::Node State
OnlyStateCreator(const StateMachine &source, StateMachine &target)
OnlySourceStateCreator(const StateMachine &source, StateMachine &target)
ManagedSynchronisedStateCreation(const std::vector< typename Ptr< StateMachine >::ConstP > &machines, const std::vector< typename Ptr< SManager >::ConstP > &managers, SManager &syncManager)
virtual std::pair< State, bool > newState(const std::vector< State > &states)
const Fsm & target() const
typename MSC::StManager StManager
ManagedBeliefStateBasedStateCreator(const StateMachine &source, StateMachine &target, const StatePropertyManager< StateProperty, StatePropertyId > &sourceStateManager, StatePropertyManager< StateProperty, StatePropertyId > &targetStateManager)
typename MSC::StatePropertyId StatePropertyId
_StatePropertyId StatePropertyId
typename FiniteAutomaton< S, I, NS, NI > ::StatePropertyId StatePropertyId
virtual std::pair< typename SC::State, bool > newState(typename SC::State source)
const Data & operator()(const MapStructure &m, size_t index) const
typename StateMachine::StatePropertyId StatePropertyId
ManagedStateCreation(const Fsm &source, Fsm &target, const StManager &sourceStateManager, StManager &targetStateManager)
Namespace of the Diades project.
virtual std::pair< State, bool > newState(const FsmBs &bs)
const StManager & _sourceStateManager
NewStateCreation(const StateMachine &source, StateMachine &target)
virtual std::pair< State, bool > newState(State source, const StatePropertyId &statePropertyId)
_EventPropertyId EventPropertyId
virtual std::pair< typename SC::State, bool > newState(typename SC::State source)
Ptr< std::vector< State > >::ConstP _pstates
Ptr< SManager >::P _syncManager
ConstIterator on the Net.
static constexpr bool isManaged()
typename Fsm::State State
typename MSC::StateProperty StateProperty
StManager & _targetStateManager
_StateProperty StateProperty
typename Fsm::EventPropertyId EventPropertyId
void setStateMachine(StateMachine &target)
static constexpr bool isManaged()
Ptr< std::vector< typename Ptr< StateMachine >::ConstP > >::ConstP _machines
typename MSC::State State
virtual std::pair< State, bool > newState(State source, const FsmBs &bs)
StatePropertyCombination::StateProperty StateProperty
typename FiniteAutomaton< S, I, NS, NI > ::State State
typename SC::StatePropertyId StatePropertyId
StateCreation(const Fsm &source, Fsm &target)
Ptr< std::vector< typename Ptr< SManager >::ConstP > >::ConstP _managers
virtual std::pair< typename SC::State, bool > newState(typename SC::State source, const typename SC::StatePropertyId &statePropertyId)
typename FiniteAutomaton< S, I, NS, NI > ::State State
typename FiniteAutomaton< S, I, NS, NI > ::StatePropertyId StatePropertyId
ManagedStateCopy(const Fsm &source, Fsm &target, const StManager &sourceStateManager, StManager &targetStateManager)