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.

84 lines
2.6 KiB

  1. //
  2. // MODULE: APGTSCAC.H
  3. //
  4. // PURPOSE: Cache (maps from a set of NID/IST pairs to a set of recommended NIDs)
  5. //
  6. // PROJECT: Generic Troubleshooter DLL for Microsoft AnswerPoint
  7. //
  8. // COMPANY: Saltmine Creative, Inc. (206)-284-7511 [email protected]
  9. //
  10. // AUTHOR: Roman Mach, Joe Mabel
  11. //
  12. // ORIGINAL DATE: 8-2-96
  13. //
  14. // NOTES:
  15. // 1. Based on Print Troubleshooter DLL
  16. //
  17. // Version Date By Comments
  18. //--------------------------------------------------------------------
  19. // V3.0 7-24-98 JM pulled out of apgts.h
  20. //
  21. #ifndef _APGTSCAC_H_DEFINED
  22. #define _APGTSCAC_H_DEFINED
  23. #if _MSC_VER >= 1000
  24. #pragma once
  25. #endif // _MSC_VER >= 1000
  26. #include <list>
  27. #include "nodestate.h"
  28. // maximum cache for belief networks
  29. #define MAXCACHESIZE 200
  30. // Maps from a set of node/state pairs to an ordered list of recommended nodes
  31. // This is all within the context of a particular belief network.
  32. class CCacheItem
  33. {
  34. private:
  35. CBasisForInference BasisForInference; // Cache key. Set of node/state pairs, not all
  36. // the nodes in the belief network, just the ones on which we
  37. // have state data from the user. State is never ST_UNKNOWN.
  38. // No "special" nodes like nidFailNode; these are all valid nodes
  39. // on which to base an inference.
  40. CRecommendations Recommendations; // Cache value. Unless nodes have been skipped, only the
  41. // first element of the vector really matters because we will
  42. // only give one recommendation at a time.
  43. public:
  44. CCacheItem() {};
  45. CCacheItem(const CBasisForInference & Basis, const CRecommendations &Rec) :
  46. BasisForInference(Basis), Recommendations(Rec)
  47. {};
  48. // note that the following makes a copy; it does not return a reference.
  49. CRecommendations GetRecommendations() const {return Recommendations;}
  50. // The following comparison operators depend on the assumption that if the cache key
  51. // is identical, the cache value will be, too.
  52. // Note that this we do not use lexicographical order. We're saying any shorter
  53. // cache key compares as less than any longer.
  54. bool operator== (const CCacheItem &item) const;
  55. bool operator!= (const CCacheItem &item) const;
  56. bool operator< (const CCacheItem &item) const;
  57. bool operator> (const CCacheItem &item) const;
  58. };
  59. class CCache
  60. {
  61. private:
  62. list<CCacheItem> listItems;
  63. enum {k_CacheSizeMax = 200};
  64. public:
  65. CCache() {};
  66. ~CCache() {};
  67. void Clear() {listItems.clear();};
  68. bool AddCacheItem(const CBasisForInference &BasisForInference, const CRecommendations &Recommendations);
  69. bool FindCacheItem(const CBasisForInference &BasisForInference, CRecommendations &Recommendations) const;
  70. UINT GetCount() const;
  71. };
  72. #endif //_APGTSCAC_H_DEFINED