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.

139 lines
2.9 KiB

  1. template<class B, class T, class P>
  2. class CEnum : public CSimpleExternalIUnknown<B>
  3. {
  4. public:
  5. // External callable methods
  6. // IEnum methods
  7. HRESULT STDMETHODCALLTYPE NextInternal(
  8. /* [in] */ ULONG celt,
  9. /* [length_is][size_is][out] */ T rgelt[],
  10. /* [out] */ ULONG *pceltFetched);
  11. HRESULT STDMETHODCALLTYPE Next(
  12. /* [in] */ ULONG celt,
  13. /* [length_is][size_is][out] */ T rgelt[],
  14. /* [out] */ ULONG *pceltFetched)
  15. {
  16. EXTERNAL_FUNC_WRAP( NextInternal( celt, rgelt, pceltFetched ) )
  17. }
  18. HRESULT STDMETHODCALLTYPE SkipInternal(
  19. /* [in] */ ULONG celt);
  20. HRESULT STDMETHODCALLTYPE Skip(
  21. /* [in] */ ULONG celt)
  22. {
  23. EXTERNAL_FUNC_WRAP( SkipInternal( celt ) )
  24. }
  25. HRESULT STDMETHODCALLTYPE ResetInternal( void );
  26. HRESULT STDMETHODCALLTYPE Reset( void )
  27. {
  28. EXTERNAL_FUNC_WRAP( ResetInternal() )
  29. }
  30. HRESULT STDMETHODCALLTYPE CloneInternal(
  31. /* [out] */ B **ppenum);
  32. HRESULT STDMETHODCALLTYPE Clone(
  33. /* [out] */ B **ppenum)
  34. {
  35. EXTERNAL_FUNC_WRAP( CloneInternal( ppenum ) )
  36. }
  37. HRESULT STDMETHODCALLTYPE GetCountInternal(
  38. /* [out] */ ULONG *puCount);
  39. HRESULT STDMETHODCALLTYPE GetCount(
  40. /* [out] */ ULONG *puCount)
  41. {
  42. EXTERNAL_FUNC_WRAP( GetCountInternal( puCount ) )
  43. }
  44. // other methods
  45. void CheckMagicValue();
  46. // internal methods
  47. CEnum();
  48. void
  49. Add(
  50. T Item
  51. );
  52. protected:
  53. virtual ~CEnum();
  54. typedef vector<T> CItemList;
  55. DWORD m_magic;
  56. PVOID m_stack[4];
  57. CSharedLock m_mutex;
  58. CItemList m_items;
  59. typename CItemList::size_type m_CurrentIndex;
  60. P m_ItemPolicy;
  61. };
  62. template <class T>
  63. class CEnumIterfaceCopyPolicy
  64. {
  65. public:
  66. void Init(T * & InitItem ) { InitItem = NULL; }
  67. void Copy(T * & DestItem, T * SourceItem )
  68. {
  69. DestItem = SourceItem;
  70. DestItem->AddRef();
  71. }
  72. void Destroy(T * & DestroyItem )
  73. {
  74. DestroyItem->Release();
  75. Init( DestroyItem );
  76. }
  77. };
  78. template <class T>
  79. class CEnumItemCopyPolicy
  80. {
  81. public:
  82. void Init(T & InitItem ) { memset( &InitItem, 0, sizeof(InitItem) ); }
  83. void Copy(T & DestItem, T SourceItem ) { DestItem = SourceItem; }
  84. void Destroy(T & DestroyItem ) { Init( DestroyItem ); }
  85. };
  86. template< class B, class T >
  87. class CEnumInterface : public CEnum<B,T*,CEnumIterfaceCopyPolicy<T> >
  88. {
  89. };
  90. template< class B, class T>
  91. class CEnumItem : public CEnum<B,T,CEnumItemCopyPolicy<T> >
  92. {
  93. };
  94. class CEnumJobs : public CEnumInterface<IEnumBackgroundCopyJobs,IBackgroundCopyJob>
  95. {
  96. public:
  97. CEnumJobs();
  98. };
  99. class CEnumFiles : public CEnumInterface<IEnumBackgroundCopyFiles,IBackgroundCopyFile>
  100. {
  101. public:
  102. CEnumFiles();
  103. };