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.

76 lines
2.5 KiB

  1. /*-----------------------------------------------------------------------------
  2. *
  3. * File: collect.h
  4. * Author: Samuel Clement (samclem)
  5. * Date: Fri Aug 13 11:43:19 1999
  6. * Description:
  7. * This defines the CCollection class. This is a object which will manage a
  8. * collection of interface pointers and pass them out as IDispatch
  9. *
  10. * History:
  11. * 13 Aug 1999: Created.
  12. *----------------------------------------------------------------------------*/
  13. #ifndef __COLLECT_H_
  14. #define __COLLECT_H_
  15. /*-----------------------------------------------------------------------------
  16. *
  17. * Class: CCollection
  18. * Synopsis: This implements a collection using the ICollection interface.
  19. * This also exposes an IEnumVARIANT interface so other callers
  20. * can use that. This represents a collection of objects only.
  21. *
  22. *---------------------------------------------------------------------------*/
  23. class ATL_NO_VTABLE CCollection :
  24. public CComObjectRootEx<CComSingleThreadModel>,
  25. public IDispatchImpl<ICollection, &IID_ICollection, &LIBID_WIALib>,
  26. public IObjectSafetyImpl<CCollection, INTERFACESAFE_FOR_UNTRUSTED_CALLER>,
  27. public IEnumVARIANT
  28. {
  29. public:
  30. CCollection();
  31. DECLARE_TRACKED_OBJECT
  32. DECLARE_NO_REGISTRY()
  33. DECLARE_PROTECT_FINAL_CONSTRUCT()
  34. BEGIN_COM_MAP(CCollection)
  35. COM_INTERFACE_ENTRY(ICollection)
  36. COM_INTERFACE_ENTRY(IDispatch)
  37. COM_INTERFACE_ENTRY(IEnumVARIANT)
  38. END_COM_MAP()
  39. STDMETHOD_(void, FinalRelease)();
  40. public:
  41. // Our methods, used locally inside of the server not exposed
  42. // via com.
  43. bool SetDispatchArray( IDispatch** rgpDispatch, unsigned long lSize );
  44. HRESULT AllocateDispatchArray( unsigned long lSize );
  45. inline unsigned long GetArrayLength() { return m_lLength; }
  46. inline IDispatch** GetDispatchArray() { return m_rgpDispatch; }
  47. HRESULT CopyFrom( CCollection* pCollection );
  48. // ICollection
  49. STDMETHOD(get_Count)( /*[out, retval]*/ long* plLength );
  50. STDMETHOD(get_Length)( /*[out, retval]*/ unsigned long* plLength );
  51. STDMETHOD(get_Item)( long Index, /*[out, retval]*/ IDispatch** ppDispItem );
  52. STDMETHOD(get__NewEnum)( /*[out, retval]*/ IUnknown** ppEnum );
  53. // IEnumVARIANT
  54. STDMETHOD(Next)( unsigned long celt, VARIANT* rgvar, unsigned long* pceltFetched );
  55. STDMETHOD(Skip)( unsigned long celt );
  56. STDMETHOD(Reset)();
  57. STDMETHOD(Clone)(IEnumVARIANT** ppEnum );
  58. protected:
  59. void FreeDispatchArray();
  60. unsigned long m_lLength;
  61. unsigned long m_lCursor;
  62. IDispatch** m_rgpDispatch;
  63. };
  64. #endif //__COLLECT_H_