Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.2 KiB

  1. //////////////////////////////////////////////////////////////////////
  2. // DbQuery.h: interface for the CDbQuery class.
  3. //
  4. // Created by JOEM 04-2000
  5. // Copyright (C) 2000 Microsoft Corporation
  6. // All Rights Reserved
  7. //
  8. /////////////////////////////////////////////////////// JOEM 4-2000 //
  9. #if !defined(AFX_DBQUERY_H__04A8E1B8_BCD4_4ABB_AC71_BDC0A04B9E98__INCLUDED_)
  10. #define AFX_DBQUERY_H__04A8E1B8_BCD4_4ABB_AC71_BDC0A04B9E98__INCLUDED_
  11. #if _MSC_VER > 1000
  12. #pragma once
  13. #endif // _MSC_VER > 1000
  14. #include "MSPromptEng.h"
  15. #include "Query.h"
  16. #include "PhoneContext.h"
  17. #include <spcollec.h>
  18. // COSTS FOR DYNAMIC PROGRAMMING
  19. #define FIXED_TRANSITION_COST 1.0
  20. #define MATCHING_TAG_COST 0.0
  21. #define NON_MATCHING_TAG_COST 10.0
  22. #define TTS_INSERT_COST 100.0
  23. #define AS_ENTRY true
  24. #define AS_TTS false
  25. // TWO HELPER CLASSES
  26. // This is the structure used to
  27. // hold the network of candidates
  28. // for the Dynamic Programing search
  29. // These were just structs (in vapi), but need copy constr.
  30. class CEquivCost
  31. {
  32. public:
  33. CEquivCost();
  34. CEquivCost(const CEquivCost& old);
  35. ~CEquivCost();
  36. WCHAR* text;
  37. CPromptEntry* entry;
  38. double cost; /* Array length: idCand.size */
  39. bool fTagMatch; // test hook: false=tags mismatch, true=tags matched
  40. int whereFrom;
  41. };
  42. class CCandidate
  43. {
  44. public:
  45. CCandidate();
  46. CCandidate(const CCandidate& old);
  47. ~CCandidate();
  48. int firstPos;
  49. int lastPos;
  50. int candMax;
  51. int candNum;
  52. int iQueryNum;
  53. CSPArray<CEquivCost*,CEquivCost*>* equivList;
  54. CCandidate* parent;
  55. };
  56. // This is the main class for handling the query list, searching
  57. // the database, and computing transition costs.
  58. class CDbQuery
  59. {
  60. public:
  61. CDbQuery();
  62. ~CDbQuery();
  63. public:
  64. HRESULT Init(IPromptDb* pIDb, CPhoneContext* pPhoneContext);
  65. HRESULT Query(CSPArray<CQuery*,CQuery*>* papQueries, double* pdCost,
  66. ISpTTSEngineSite* pOutputSite, bool *fAbort);
  67. HRESULT Reset();
  68. private:
  69. HRESULT SearchId(const WCHAR* pszId);
  70. HRESULT SearchBackup(const WCHAR* pszText);
  71. HRESULT SearchText(WCHAR* pszText, const CSPArray<CDynStr,CDynStr>* tags);
  72. HRESULT Backtrack(double* pdCost);
  73. HRESULT ComputeCostsText(CCandidate* child, const WCHAR* pszText);
  74. HRESULT ComputeCosts(CCandidate* parent, CCandidate* child, const CSPArray<CDynStr,CDynStr>* tags,
  75. CSPArray<CDynStr,CDynStr>* idList, const bool asEntry, double* dCandCost);
  76. HRESULT ComputeCostsId(CCandidate* child, IPromptEntry* pIPE);
  77. HRESULT CostFunction(CEquivCost* prev, CEquivCost* cur, const CSPArray<CDynStr,CDynStr>* tags,
  78. double* cost);
  79. HRESULT RemoveLocalQueries(const USHORT unQueryNum);
  80. HRESULT CopyEntry(IPromptEntry* pIPE, CPromptEntry** inEntry );
  81. private:
  82. int m_iCurrentQuery;
  83. CPhoneContext* m_pPhoneContext;
  84. IPromptDb* m_pIDb;
  85. ISpTTSEngineSite* m_pOutputSite;
  86. CSPArray<CQuery*,CQuery*>* m_papQueries;
  87. CSPArray<CCandidate*,CCandidate*> m_apCandidates;
  88. CSPArray<CCandidate*,CCandidate*> m_apCandEnd;
  89. bool m_fAbort;
  90. };
  91. #endif // !defined(AFX_DBQUERY_H__04A8E1B8_BCD4_4ABB_AC71_BDC0A04B9E98__INCLUDED_)