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.

179 lines
5.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: daholder.h
  7. //
  8. // Contents: CDAHolder, concrete version of IDataAdviseHolder
  9. //
  10. // Classes: CDAHolder
  11. //
  12. // Functions:
  13. //
  14. // History: dd-mmm-yy Author Comment
  15. // 06-Feb-95 t-ScottH created - split class definition from
  16. // cpp file (for debug purposes)
  17. // - added Dump method to CDAHolder
  18. //
  19. //--------------------------------------------------------------------------
  20. #ifndef _DAHOLDER_H_
  21. #define _DAHOLDER_H_
  22. #ifdef _DEBUG
  23. #include <dbgexts.h>
  24. #endif // _DEBUG
  25. //+----------------------------------------------------------------------------
  26. //
  27. // Class:
  28. // CDAHolder
  29. //
  30. // Purpose:
  31. // provides concrete implementation of IDataAdviseHolder
  32. //
  33. // Interface:
  34. // IDataAdviseHolder
  35. //
  36. // Notes:
  37. // REVIEW, not thread safe, under assumption that docs cant be MT
  38. //
  39. // Connections are numbered from [1..infinity). We don't use
  40. // zero to avoid getting caught on someone else's zero init'ed
  41. // memory. Zero is checked for as a connection number on entry
  42. // to routines, and rejected. This allows us to use zero as
  43. // a way to mark unused STATDATA entries in our array.
  44. //
  45. // History:
  46. // 06-Feb-95 t-Scotth added Dump method (_DEBUG only)
  47. // 01/24/94 - AlexGo - now inherit from CPrivAlloc
  48. // 10/29/93 - ChrisWe - file inspection and cleanup
  49. //
  50. //-----------------------------------------------------------------------------
  51. // NOTE: CDAHolder MUST inherit from IDataAdviseHolder first in order for the
  52. // DumpCDAHolder function to work since we cast the IDataAdviseHolder as a
  53. // CDAHolder (if it inherits from IDataAdviseHolder first, then the pointers
  54. // are the same)
  55. class FAR CDAHolder : public IDataAdviseHolder, public CSafeRefCount
  56. {
  57. public:
  58. CDAHolder();
  59. // *** IUnknown methods ***
  60. STDMETHOD(QueryInterface) (REFIID riid, LPVOID FAR* ppv);
  61. STDMETHOD_(ULONG,AddRef) () ;
  62. STDMETHOD_(ULONG,Release) ();
  63. // *** IDataAdviseHolder methods ***
  64. STDMETHOD(Advise)(LPDATAOBJECT pDataObj, FORMATETC FAR* pFetc,
  65. DWORD advf, IAdviseSink FAR* pAdvSink,
  66. DWORD FAR* pdwConnection);
  67. STDMETHOD(Unadvise)(DWORD dwConnection);
  68. STDMETHOD(EnumAdvise)(IEnumSTATDATA FAR* FAR* ppenumAdvise);
  69. STDMETHOD(SendOnDataChange)(IDataObject FAR* pDataObject,
  70. DWORD dwReserved, DWORD advf);
  71. // *** debug and dump methods ***
  72. #ifdef _DEBUG
  73. HRESULT Dump(char **ppszDump, ULONG ulFlag, int nIndentLevel);
  74. // need to be able to access CDAHolder private data members in the
  75. // following debugger extension APIs
  76. // this allows the debugger extension APIs to copy memory from the
  77. // debuggee process memory to the debugger's process memory
  78. // this is required since the Dump method follows pointers to other
  79. // structures and classes
  80. friend DEBUG_EXTENSION_API(dump_daholder);
  81. friend DEBUG_EXTENSION_API(dump_enumstatdata);
  82. friend DEBUG_EXTENSION_API(dump_dataadvisecache);
  83. friend DEBUG_EXTENSION_API(dump_defobject);
  84. friend DEBUG_EXTENSION_API(dump_deflink);
  85. #endif // _DEBUG
  86. private:
  87. ~CDAHolder();
  88. DWORD m_dwConnection; // next connection number to use
  89. int m_iSize; // number of stat data elements in array
  90. STATDATA FAR *m_pSD; // array of STATDATA elements
  91. #define CDAHOLDER_GROWBY 5 /* number of entries to grow array by each time */
  92. SET_A5;
  93. // the enumerator returned by the EnumAdvise method
  94. friend class CEnumSTATDATA;
  95. };
  96. //+----------------------------------------------------------------------------
  97. //
  98. // Class:
  99. // CEnumSTATDATA
  100. //
  101. // Purpose:
  102. // is the enumerator returned by CDAHolder::Enum
  103. //
  104. // Interface:
  105. // IEnumSTATDATA
  106. //
  107. // Notes:
  108. // Keeps the underlying CDAHolder alive for the lifetime of
  109. // the enumerator.
  110. //
  111. // History:
  112. // 10/29/93 - ChrisWe - file inspection and cleanup
  113. //
  114. //-----------------------------------------------------------------------------
  115. class CEnumSTATDATA : public IEnumSTATDATA, public CPrivAlloc
  116. {
  117. public:
  118. CEnumSTATDATA(CDAHolder FAR* pHolder, int iDataStart);
  119. // *** IUnknown methods ***
  120. STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR* ppv);
  121. STDMETHOD_(ULONG,AddRef)() ;
  122. STDMETHOD_(ULONG,Release)();
  123. // *** IEnumSTATDATA methods ***
  124. STDMETHOD(Next)(ULONG celt, STATDATA FAR * rgelt,
  125. ULONG FAR* pceltFetched);
  126. STDMETHOD(Skip)(ULONG celt);
  127. STDMETHOD(Reset)();
  128. STDMETHOD(Clone)(LPENUMSTATDATA FAR* ppenum);
  129. #ifdef _DEBUG
  130. HRESULT Dump(char **ppszDump, ULONG ulFlag, int nIndentLevel);
  131. // need to be able to access CEnumSTATDATA private data members in the
  132. // following debugger extension APIs
  133. // this allows the debugger extension APIs to copy memory from the
  134. // debuggee process memory to the debugger's process memory
  135. // this is required since the Dump method follows pointers to other
  136. // structures and classes
  137. friend DEBUG_EXTENSION_API(dump_enumstatdata);
  138. #endif // _DEBUG
  139. private:
  140. ~CEnumSTATDATA();
  141. ULONG m_refs; // reference count
  142. int m_iDataEnum; // index of the next element to return
  143. CDAHolder FAR* m_pHolder; // pointer to holder; is ref counted
  144. SET_A5;
  145. };
  146. #endif // _DAHOLDER_H_
  147.