Leaked source code of windows server 2003
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.

82 lines
2.4 KiB

  1. // Copyright (c) 1999 Microsoft Corporation. All rights reserved.
  2. //
  3. // Templated base class CAutBaseImp for constructing automation interfaces.
  4. // Implements aggregation and IDispatched based on a table of method information.
  5. //
  6. #pragma once
  7. #include "authelper.h"
  8. // Inherit your class from CAutBaseImp with the following template types:
  9. // * T_derived is the type of your class itself.
  10. // * T_ITarget is the DirectMusic interface you are implemention automation for.
  11. // * T_piid is the address of the IID of T_ITarget.
  12. // Your class must have the following public static members:
  13. // * static const AutDispatchMethod ms_Methods[];
  14. // This table describes your methods and their parameters.
  15. // * static const DispatchHandlerEntry<T_derived> ms_Handlers[];
  16. // This table designates member functions on your class that will be called when
  17. // your methods are invoked.
  18. // * static const WCHAR ms_wszClassName[];
  19. // This is the name of your class that will be output in the debug log
  20. // as your functions are called.
  21. // See autperformance.h and autperformance.cpp for an example of using this base class.
  22. template <class T_derived>
  23. struct DispatchHandlerEntry
  24. {
  25. typedef HRESULT (T_derived::* pmfnDispatchHandler)(AutDispatchDecodedParams *paddp);
  26. DISPID dispid;
  27. pmfnDispatchHandler pmfn;
  28. };
  29. template <class T_derived, class T_ITarget, const IID *T_piid>
  30. class CAutBaseImp
  31. : public CAutUnknown::CAutUnknownParent,
  32. public IDispatch
  33. {
  34. public:
  35. // IUnknown
  36. STDMETHOD(QueryInterface)(const IID &iid, void **ppv);
  37. STDMETHOD_(ULONG, AddRef)();
  38. STDMETHOD_(ULONG, Release)();
  39. // IDispatch
  40. STDMETHOD(GetTypeInfoCount)(UINT *pctinfo);
  41. STDMETHOD(GetTypeInfo)(UINT iTInfo, LCID lcid, ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
  42. STDMETHOD(GetIDsOfNames)(
  43. REFIID riid,
  44. LPOLESTR __RPC_FAR *rgszNames,
  45. UINT cNames,
  46. LCID lcid,
  47. DISPID __RPC_FAR *rgDispId);
  48. STDMETHOD(Invoke)(
  49. DISPID dispIdMember,
  50. REFIID riid,
  51. LCID lcid,
  52. WORD wFlags,
  53. DISPPARAMS __RPC_FAR *pDispParams,
  54. VARIANT __RPC_FAR *pVarResult,
  55. EXCEPINFO __RPC_FAR *pExcepInfo,
  56. UINT __RPC_FAR *puArgErr);
  57. protected:
  58. CAutBaseImp(
  59. IUnknown* pUnknownOuter,
  60. const IID& iid,
  61. void** ppv,
  62. HRESULT *phr);
  63. virtual ~CAutBaseImp() {}
  64. T_ITarget *m_pITarget;
  65. private:
  66. CAutUnknown m_UnkControl;
  67. virtual void Destroy();
  68. };
  69. #include "autbaseimp.inl"