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.

98 lines
2.2 KiB

  1. #ifndef __BUFMGR_H__
  2. #define __BUFMGR_H__
  3. #include "netutils.h" //NETNAMELIST
  4. #include <map>
  5. using namespace std;
  6. #define WM_USER_GETDATA_THREAD_DONE WM_USER + 200
  7. enum BUFFER_ENTRY_TYPE {
  8. BUFFER_ENTRY_TYPE_VALID = 0,
  9. BUFFER_ENTRY_TYPE_ERROR,
  10. BUFFER_ENTRY_TYPE_INPROGRESS
  11. };
  12. class CEntryData
  13. {
  14. public:
  15. CComBSTR m_bstrNodeName;
  16. NODETYPE m_nNodeType;
  17. HTREEITEM m_hItem;
  18. NETNAMELIST* m_pList;
  19. HRESULT m_hr;
  20. CEntryData(LPCTSTR pszNodeName, NODETYPE nNodeType, HTREEITEM hItem);
  21. ~CEntryData();
  22. inline LPCTSTR GetNodeName() { return m_bstrNodeName; }
  23. inline NODETYPE GetNodeType() { return m_nNodeType; }
  24. inline HTREEITEM GetTreeItem() { return m_hItem; }
  25. inline NETNAMELIST* GetList() { return m_pList; }
  26. inline HRESULT GetEntryHRESULT() { return m_hr; };
  27. void SetEntry(PVOID pList, HRESULT hr);
  28. enum BUFFER_ENTRY_TYPE GetEntryType();
  29. void ReSet();
  30. };
  31. struct mapcmpfn
  32. {
  33. bool operator()(PTSTR p1, PTSTR p2) const
  34. {
  35. return lstrcmpi(p1, p2) < 0;
  36. }
  37. };
  38. typedef map<PTSTR, CEntryData *, mapcmpfn> Cache;
  39. class CBufferManager
  40. {
  41. private:
  42. LONG m_cRef; // instance reference count
  43. HWND m_hDlg; // the owner dialog which owns this instance
  44. LONG m_lContinue; // synchronization flag between owner dialog and all the related running threads
  45. CRITICAL_SECTION m_CriticalSection; // synchronize access to the buffer
  46. Cache m_map; // NodeName ==> CEntryData*. The Buffer.
  47. void FreeBuffer();
  48. // constructor
  49. CBufferManager(HWND hDlg);
  50. // destructor
  51. ~CBufferManager();
  52. public:
  53. static HRESULT CreateInstance(
  54. IN HWND hDlg,
  55. OUT CBufferManager **ppBufferManager
  56. );
  57. LONG AddRef();
  58. LONG Release();
  59. void SignalExit();
  60. BOOL ShouldExit();
  61. HRESULT LoadInfo(
  62. IN PCTSTR pszNodeName,
  63. IN NODETYPE nNodeType,
  64. IN HTREEITEM hItem,
  65. OUT CEntryData **ppInfo
  66. );
  67. HRESULT AddInfo(
  68. IN PCTSTR pszNodeName,
  69. IN PVOID pList,
  70. IN HRESULT hr,
  71. OUT PVOID* ppv
  72. );
  73. void ThreadReport(
  74. IN PVOID ptr,
  75. IN HRESULT hr
  76. );
  77. HRESULT StartThread(
  78. IN PCTSTR pszNodeName,
  79. IN NODETYPE nNodeType
  80. );
  81. };
  82. #endif // __BUFMGR_H__