mlNavigationHelper.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef NULLSOFT_WINAMP_ML_NAVIGATION_HELPER_HEADER
  2. #define NULLSOFT_WINAMP_ML_NAVIGATION_HELPER_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include "./ifc_mlnavigationhelper.h"
  7. #include "./ifc_omcachecallback.h"
  8. #include <vector>
  9. #include <map>
  10. #include <bfc/multipatch.h>
  11. class ifc_omcachemanager;
  12. class ifc_omcachegroup;
  13. class ifc_mlnavigationcallback;
  14. #define MPIID_MLNAVIGATIONHELPER 10
  15. #define MPIID_OMCACHECALLBACK 20
  16. class MlNavigationHelper : public MultiPatch<MPIID_MLNAVIGATIONHELPER, ifc_mlnavigationhelper>,
  17. public MultiPatch<MPIID_OMCACHECALLBACK, ifc_omcachecallback>
  18. {
  19. protected:
  20. MlNavigationHelper(HWND hLibrary, ifc_omcachegroup *cacheGroup);
  21. ~MlNavigationHelper();
  22. public:
  23. static HRESULT CreateInstance(HWND hLibrary, ifc_omcachemanager *cacheManager, MlNavigationHelper **instance);
  24. public:
  25. /* Dispatchable */
  26. size_t AddRef();
  27. size_t Release();
  28. int QueryInterface(GUID interface_guid, void **object);
  29. /* ifc_mlnavigationhelper */
  30. HRESULT GetDefaultIndex(INT *index);
  31. HRESULT QueryIndex(LPCWSTR pszName, INT *index, BOOL *defaultUsed);
  32. HRESULT ReleaseIndex(LPCWSTR pszName);
  33. HRESULT RegisterAlias(LPCWSTR pszName, LPCWSTR pszAddress);
  34. HRESULT RegisterCallback(ifc_mlnavigationcallback *callback, UINT *cookie);
  35. HRESULT UnregisterCallback(UINT cookie);
  36. /* ifc_omcachecallback */
  37. void CacheRecordPathChanged(ifc_omcacherecord *cacheRecord);
  38. protected:
  39. void CacheRecordPathChangedApc(ifc_omcacherecord *cacheRecord);
  40. private:
  41. friend static void CALLBACK MlNavigationHelper_CacheRecordPathChangedApc(ULONG_PTR data);
  42. public:
  43. HWND GetLibrary();
  44. protected:
  45. typedef struct __RECORD
  46. {
  47. LPWSTR name;
  48. INT index;
  49. UINT ref;
  50. } RECORD;
  51. typedef std::vector<RECORD> RecordList;
  52. typedef std::vector<INT> RecycledList;
  53. typedef std::map<UINT, ifc_mlnavigationcallback*> CallbackMap;
  54. private:
  55. friend __inline static int __cdecl MlNavigationHelper_RecordComparer(const void *elem1, const void *elem2);
  56. friend __inline static int __cdecl MlNavigationHelper_RecordSearch(const void *elem1, const void *elem2);
  57. HRESULT ImageLocator(LPCWSTR address, INT *index);
  58. HRESULT UpdateImageList(LPCWSTR address, INT *index);
  59. HRESULT Sort();
  60. RECORD *Find(LPCWSTR pszName);
  61. protected:
  62. ULONG ref;
  63. HWND hLibrary;
  64. INT defaultIndex;
  65. ifc_omcachegroup *cacheGroup;
  66. RecordList recordList;
  67. CallbackMap callbackMap;
  68. RecycledList recycledList;
  69. UINT lastCookie;
  70. CRITICAL_SECTION lock;
  71. protected:
  72. RECVS_MULTIPATCH;
  73. };
  74. #endif //NULLSOFT_WINAMP_ML_NAVIGATION_HELPER_HEADER