/// \brief add state's available event labels to the set /// \param labels - result set with labels /// \param addInternal - if value set to false then entry, update and exit /// events are not added to the label list void CQHState::GetAvailableEventLabels( set<IHashString *, LessIHashString> &labels, bool addInternal ) { CQHState *parent = GetParentState(); if( parent != NULL ) { parent->GetAvailableEventLabels( labels, false ); } IDTOEVENTMAP::iterator it = m_Events.begin(); if( addInternal ) { for( ; it != m_Events.end(); ++it ) { assert( !it->second->GetEventName()->IsEmpty() ); labels.insert( it->second->GetEventName() ); } } else { for( ; it != m_Events.end(); ++it ) { IHashString *eventName = it->second->GetEventName(); if( m_EntryEvent != *eventName && m_UpdateEvent != *eventName && m_ExitEvent != *eventName ) { assert( !eventName->IsEmpty() ); labels.insert( eventName ); } } } }
int8_t StateIsChildOf(State* state, State* possibleAncestor) { int8_t result = 0; if (state) { State* possibleParent = GetParentState(state); while(possibleParent) { if(possibleParent == possibleAncestor) { result = 1; break; } possibleParent = GetParentState(possibleParent); } } return result; }
CQHStateMachineEvent *CQHState::GetEvent( IHashString *aeventName ) { const DWORD hashName = aeventName->GetUniqueID(); IDTOEVENTMAP::iterator it = m_EventsByLabel.find( hashName ); if( it != m_EventsByLabel.end() ) { return dynamic_cast<CQHStateMachineEvent*>( it->second ); } CQHState *parentState = GetParentState(); if( parentState != NULL ) { return parentState->GetEvent( aeventName ); } return NULL; }
void CQHState::GenerateAvailableEventsList( OBJECTLIST *availableEvents ) { CQHState *parentState = GetParentState(); if( parentState != NULL ) { parentState->GenerateAvailableEventsList( availableEvents ); } IDTOEVENTMAP::iterator eventsIterator = m_Events.begin(); for( ; eventsIterator != m_Events.end(); eventsIterator++ ) { CQHStateMachineEvent *iteratedEvent = eventsIterator->second; IHashString *eventName = iteratedEvent->GetEventName(); if( parentState == NULL || parentState->GetEvent( eventName ) == NULL ) { availableEvents->push_back( iteratedEvent ); } } }
bool CQHState::IsBaseParent( CQHState *atestState ) { bool areturn = false; CQHState *aiteratedParent = GetParentState(); while( !areturn && aiteratedParent != NULL ) { if( aiteratedParent == atestState ) { areturn = true; } else { aiteratedParent = aiteratedParent->GetParentState(); } } return areturn; }