/**************************************************************************** * CRecoEventMgr::CleanUp * *------------------------* * Description: * Deletes all nodes. * Resends the queued messages and cleans up the queue *****************************************************************************/ void CRecoEventMgr::CleanUp() { m_fPhraseStarted = false; // Remove any hypothesis text for ( LISTENPOINT *p = m_pHeadLP; p; p = p->pNext ) { if ( p->fHasHypothesisText && p->cpRangeToReplace ) { p->cpRangeToReplace->SetText( L"" ); } } // Clean up the listen point list if ( m_pHeadLP ) { DeleteAfter( m_pHeadLP ); delete m_pHeadLP; m_pHeadLP = NULL; } // Resend the WM_x messages that had been waiting during the computation // on the phrase and clean up the queue QUEUEDWM *pWM; while ( m_pHeadWM ) { pWM = m_pHeadWM; ::SendMessage( pWM->hWnd, pWM->message, pWM->wParam, pWM->lParam ); m_pHeadWM = m_pHeadWM->pNext; delete pWM; } m_pHeadWM = m_pTailWM = NULL; } /* CRecoEventMgr::CleanUp */
// Delete completed edges. Update 'xIntersect' field for others void UpdateActiveList(ILint scan, Edge *active) { Edge *q = active, *p = active->next; while (p) { if (scan >= p->yUpper) { p = p->next; DeleteAfter(q); } else { p->xIntersect = p->xIntersect + p->dxPerScan; q = p; p = p->next; } } }
/// /// UpdateActiveList() VOID UpdateActiveList( int scan, EdgePtr active ) { EdgePtr p, q; q = active; p = active->next; while( p ) { if( scan >= p->yUpper ) { p = p->next; DeleteAfter( q ); } else { p->xIntersect = p->xIntersect + p->dxPerScan; q = p; p = p->next; } } }
RBNode* Delete(RBNode** Root, int Data) { RBNode* Deleted = NULL; RBNode* Successor = NULL; RBNode* Target = Search((*Root), Data); if(Target == NULL) return NULL; if(Target->Left == &Nil || Target->Right == &Nil) Deleted = Target; else { Deleted = SearchMin(Target->Right); Target->Data = Deleted->Data; } if(Deleted->Left != &Nil) Successor = Deleted->Left; else Successor = Deleted->Right; Successor->Parent = Deleted->Parent; if(Deleted->Parent ==NULL) (*Root) = Successor; else { if(Deleted == Deleted->Parent->Left) Deleted->Parent->Left = Successor; else Deleted->Parent->Right = Successor; } if(Deleted->Color == Black) DeleteAfter(Root,Successor); return Deleted; }
/**************************************************************************** * CRecoEventMgr::Recognition * *----------------------------* * Description: * Called whenever a recognition comes back to DictationPad. * Looks for the latest listening point whose timestamp predates * ftRecoTime or for the phrase-start-generated listening point, * whichever came later. * Deletes all earlier listening points. * Hands back a duplicate of the range to be replaced by the recognized * text. * Return: * S_OK * S_FALSE if the recognition was from some phrase that was started * when our grammars were inactive. * Return value from ITextRange::GetDuplicate() *****************************************************************************/ HRESULT CRecoEventMgr::Recognition( FILETIME ftRecoTime, ITextRange **ppRecoRange ) { // A SPEI_RECOGNITION without a SPEI_PHRASE_START means that the phrase was // started when our grammars were inactive, so we'd like to ignore this one. if ( !m_fPhraseStarted || !m_pHeadLP ) { return S_FALSE; } // Since the listen points are ordered by most recent first, we are // looking for the first element whose timestamp predates ftRecoTime LISTENPOINT *p; for ( p = m_pHeadLP; p && (CompareFiletimes( ftRecoTime, p->ftTime ) < 0) && !(p->fFromPhraseStart); p = p->pNext ) ; _ASSERTE( p ); if ( !p ) { // Should not happen! return E_UNEXPECTED; } // Get rid of all subsequent (earlier) listening points DeleteAfter( p ); // Get the range to return. // Make a duplicate, since this range will be destroyed before the caller // can AddRef it. HRESULT hr = p->cpRangeToReplace->GetDuplicate( ppRecoRange ); // This listen point will now contain real (non-hypothesis) text p->fHasHypothesisText = false; // p will get cleaned up later when DoneProcessingPhrase() is called return hr; } /* CRecoEventMgr::Recognition */
/**************************************************************************** * CRecoEventMgr::FalseRecognition * *---------------------------------* * Description: * Called whenever a false recognition comes back to Dictpad. * Finds the phrase-start-marked listen point * and deletes everything after it *****************************************************************************/ void CRecoEventMgr::FalseRecognition() { if ( !m_fPhraseStarted || !m_pHeadLP ) { // This means that this is a RECO_OTHER_CONTEXT, or a recognition for // a grammar other than dictation within our own context, neither of // which we care about return; } // Clean up anything that happened before the start of this utterance for ( LISTENPOINT *p = m_pHeadLP; p && !(p->fFromPhraseStart); p = p->pNext ) { ; } if ( p ) { DeleteAfter( p ); } // p will get cleaned up later when DoneProcessingPhrase() is called } /* CRecoEventMgr::FalseRecognition */