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.

97 lines
2.9 KiB

  1. // Copyright (c) 2000 Microsoft Corporation. All rights reserved.
  2. //
  3. // Declaration of CContainerDispatch.
  4. //
  5. #pragma once
  6. #include "smartref.h"
  7. #include "unkhelp.h"
  8. #include "dmusicp.h"
  9. class CContainerItemDispatch
  10. : public IDispatch,
  11. public ComSingleInterface
  12. {
  13. public:
  14. CContainerItemDispatch(IDirectMusicLoader *pLoader, const WCHAR *wszAlias, const DMUS_OBJECTDESC &desc, bool fPreload, bool fAutodownload, HRESULT *phr);
  15. ~CContainerItemDispatch();
  16. const WCHAR *Alias() { return m_wstrAlias; }
  17. IDispatch *Item() { if (m_pDispLoadedItem) return m_pDispLoadedItem; return this; } // returns the contained item when loaded, otherwise itself so Load can be called
  18. // IUnknown
  19. ComSingleInterfaceUnknownMethods(IDispatch)
  20. // IDispatch
  21. STDMETHOD(GetTypeInfoCount)(UINT *pctinfo) { return E_NOTIMPL; }
  22. STDMETHOD(GetTypeInfo)(UINT iTInfo, LCID lcid, ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo) { return E_NOTIMPL; }
  23. STDMETHOD(GetIDsOfNames)(
  24. REFIID riid,
  25. LPOLESTR __RPC_FAR *rgszNames,
  26. UINT cNames,
  27. LCID lcid,
  28. DISPID __RPC_FAR *rgDispId);
  29. STDMETHOD(Invoke)(
  30. DISPID dispIdMember,
  31. REFIID riid,
  32. LCID lcid,
  33. WORD wFlags,
  34. DISPPARAMS __RPC_FAR *pDispParams,
  35. VARIANT __RPC_FAR *pVarResult,
  36. EXCEPINFO __RPC_FAR *pExcepInfo,
  37. UINT __RPC_FAR *puArgErr);
  38. // If it is a segment or song, download it if needed.
  39. // If it is a script, init it.
  40. // If it is a song, compose it.
  41. enum InitWithPerfomanceFailureType { IWP_Success, IWP_DownloadFailed, IWP_ScriptInitFailed };
  42. HRESULT InitWithPerformance(IDirectMusicPerformance *pPerf, InitWithPerfomanceFailureType *peFailureType);
  43. private:
  44. void ReleaseLoader();
  45. HRESULT Load(bool fDynamicLoad);
  46. HRESULT DownloadOrUnload(bool fDownload, IDirectMusicPerformance *pPerf);
  47. SmartRef::WString m_wstrAlias;
  48. IDirectMusicLoader *m_pLoader; // note: use AddRefP/ReleaseP
  49. IDirectMusicLoader8P *m_pLoader8P; // note: use AddRefP/ReleaseP
  50. DMUS_OBJECTDESC m_desc;
  51. bool m_fLoaded;
  52. IDispatch *m_pDispLoadedItem;
  53. bool m_fAutodownload;
  54. IDirectMusicPerformance *m_pPerfForUnload;
  55. };
  56. class CContainerDispatch
  57. {
  58. public:
  59. CContainerDispatch(IDirectMusicContainer *pContainer, IDirectMusicLoader *pLoader, DWORD dwScriptFlags, HRESULT *phr);
  60. ~CContainerDispatch();
  61. HRESULT OnScriptInit(IDirectMusicPerformance *pPerf); // gives the container a chance to do auto downloading/composing during script initialization
  62. HRESULT GetIDsOfNames(
  63. REFIID riid,
  64. LPOLESTR __RPC_FAR *rgszNames,
  65. UINT cNames,
  66. LCID lcid,
  67. DISPID __RPC_FAR *rgDispId);
  68. HRESULT Invoke(
  69. DISPID dispIdMember,
  70. REFIID riid,
  71. LCID lcid,
  72. WORD wFlags,
  73. DISPPARAMS __RPC_FAR *pDispParams,
  74. VARIANT __RPC_FAR *pVarResult,
  75. EXCEPINFO __RPC_FAR *pExcepInfo,
  76. UINT __RPC_FAR *puArgErr);
  77. // For use by the script object
  78. HRESULT EnumItem(DWORD dwIndex, WCHAR *pwszName);
  79. HRESULT GetVariableObject(WCHAR *pwszVariableName, IUnknown **ppunkValue);
  80. private:
  81. SmartRef::Vector<CContainerItemDispatch *> m_vecItems;
  82. bool m_fDownloadOnInit;
  83. };