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.

78 lines
2.4 KiB

  1. /////////////////////////////////////////////////////////////////////////////////////
  2. // Components.h : Declaration of the CComponents
  3. // Copyright (c) Microsoft Corporation 1999.
  4. #ifndef __COMPONENTS_H_
  5. #define __COMPONENTS_H_
  6. #pragma once
  7. #include <objectwithsiteimplsec.h>
  8. #include "component.h"
  9. typedef std::vector<PQComponent, stl_smart_ptr_allocator<PQComponent> > ComponentList;
  10. /////////////////////////////////////////////////////////////////////////////
  11. // CComponent
  12. class ATL_NO_VTABLE CComponents :
  13. public CComObjectRootEx<CComMultiThreadModel>,
  14. public IObjectWithSiteImplSec<CComponents>,
  15. public IDispatchImpl<IComponents, &IID_IComponents, &LIBID_TunerLib>
  16. {
  17. public:
  18. CComponents()
  19. {
  20. }
  21. DECLARE_NOT_AGGREGATABLE(CComponents)
  22. DECLARE_PROTECT_FINAL_CONSTRUCT()
  23. BEGIN_COM_MAP(CComponents)
  24. COM_INTERFACE_ENTRY(IComponents)
  25. COM_INTERFACE_ENTRY(IDispatch)
  26. COM_INTERFACE_ENTRY(IObjectWithSite)
  27. END_COM_MAP_WITH_FTM()
  28. public:
  29. ComponentList m_Components;
  30. // IComponents
  31. public:
  32. STDMETHOD(get__NewEnum)(/*[out, retval]*/ IEnumVARIANT* *pVal);
  33. STDMETHOD(EnumComponents)(/*[out, retval]*/ IEnumComponents** pVal);
  34. STDMETHOD(get_Count)(/*[out, retval]*/ long *pVal);
  35. STDMETHOD(get_Item)(/*[in]*/ VARIANT varIndex, /*[out, retval]*/ IComponent **ppComponent);
  36. STDMETHOD(Add)(/*[in]*/ IComponent *pComponent, VARIANT *pNewIndex);
  37. STDMETHOD(Remove)(VARIANT varIndex);
  38. STDMETHOD(Clone)(IComponents **ppNewList);
  39. };
  40. typedef CComQIPtr<IComponents> PQComponents;
  41. class CopyComponentToVARIANT {
  42. public:
  43. static HRESULT copy(VARIANT *pv, IComponent** p) {
  44. VariantClear(pv);
  45. pv->vt = VT_UNKNOWN;
  46. pv->punkVal = *p;
  47. pv->punkVal->AddRef();
  48. return NOERROR;
  49. }
  50. static void init(VARIANT *v) { VariantInit(v); }
  51. static void destroy(VARIANT *v) { VariantClear(v); }
  52. };
  53. typedef CComObject<CComEnumOnSTL<IEnumVARIANT, &__uuidof(IEnumVARIANT),
  54. VARIANT,
  55. CopyComponentToVARIANT,
  56. ComponentList,
  57. CComMultiThreadModel> > ComponentEnumerator_t;
  58. typedef CComObject<CComEnumOnSTL<IEnumComponents, &__uuidof(IEnumComponents),
  59. IComponent *,
  60. _CopyInterface<IComponent>,
  61. ComponentList,
  62. CComMultiThreadModel> > ComponentBaseEnumerator_t;
  63. #endif //__COMPONENTS_H_