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.

135 lines
4.7 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File:
  4. // dacache.h
  5. //
  6. // Classes:
  7. // CDataAdviseCache
  8. //
  9. // Functions:
  10. //
  11. // History:
  12. // 31-Jan-95 t-ScottH add Dump method to CDataAdviseCache class
  13. // 24-Jan-94 alexgo first pass at converting to Cairo-style
  14. // memory allocation
  15. // 11/02/93 - ChrisWe - file inspection and cleanup
  16. //
  17. //-----------------------------------------------------------------------------
  18. #ifndef _DACACHE_H_
  19. #define _DACACHE_H_
  20. #ifdef _DEBUG
  21. #include <dbgexts.h>
  22. #endif // _DEBUG
  23. #include <map_dwdw.h>
  24. //+----------------------------------------------------------------------------
  25. //
  26. // Class:
  27. // CDataAdviseCache
  28. //
  29. // Purpose:
  30. // A CDataAdviseCache is used to remember data advises across
  31. // loaded<-->running transitions. The data advise cache holds
  32. // on to advise sinks that are interested in data, even if there
  33. // is no data object, because the server is not activated.
  34. // These advise sinks can be registered with a running data object
  35. // later on, when it is activated, or they can be Unadvised()
  36. // if the object is to go inactive.
  37. //
  38. // Interface:
  39. // Advise - add a new advise sink for the indicated data object,
  40. // if there is one; if no data object, record the
  41. // advise sink for future use
  42. //
  43. // Unadvise - remove an advise sink from the advise sink cache,
  44. // and from the data object, if there is one
  45. //
  46. // EnumAdvise - enumerate all the registered advise sinks
  47. //
  48. // ClientToDelegate - Maps a client connection number to a
  49. // delegate connection number. Client connection numbers
  50. // are those returned by Advise(), while the delegate
  51. // connection numbers are those used by the data object
  52. // itself.
  53. //
  54. // EnumAndAdvise - A data object has become newly active (or
  55. // has just been deactivated.) This will enumerate all
  56. // the registered advise sinks, and call Advise() (or
  57. // Unadvise()) on the data object.
  58. //
  59. // CreateDataAdviseCache - creates an instance of the
  60. // CDataAdviseCache; there is no public constructor,
  61. // because internal data structures must be allocated,
  62. // and these allocations could fail. There is no way
  63. // to indicate such a failure when using "new," so
  64. // clients are required to use this function instead.
  65. //
  66. // ~CDataAdviseCache
  67. //
  68. // Notes:
  69. // This is an internal helper class, and does not support any
  70. // interfaces.
  71. //
  72. // Because a connection number must be returned even in the loaded
  73. // state, there must be two sets of connection numbers: client
  74. // numbers are "fake" connection numbers returned to the caller;
  75. // delegate numbers are those returned by the "real" running
  76. // object. We maintain a map from client numbers to delegate
  77. // numbers. If not running, our client numbers map to zero.
  78. // Client numbers also map to zero if the delegate refused the
  79. // Advise when it began to run. We use a DWORD->DWORD map.
  80. //
  81. // History:
  82. // 31-Jan-95 t-ScottH add Dump method (_DEBUG only)
  83. // 11/02/93 - ChrisWe - file inspection and cleanup
  84. //
  85. //-----------------------------------------------------------------------------
  86. class FAR CDataAdviseCache : public CPrivAlloc
  87. {
  88. public:
  89. HRESULT Advise(LPDATAOBJECT pDataObject, FORMATETC FAR* pFetc,
  90. DWORD advf, LPADVISESINK pAdvise,
  91. DWORD FAR* pdwClient);
  92. // first 4 parms are as in DataObject::Advise
  93. HRESULT Unadvise(IDataObject FAR* pDataObject, DWORD dwClient);
  94. HRESULT EnumAdvise(LPENUMSTATDATA FAR* ppenumAdvise);
  95. HRESULT EnumAndAdvise(LPDATAOBJECT pDataObject, BOOL fAdvise);
  96. // Advise or Unadvise
  97. static FARINTERNAL CreateDataAdviseCache(
  98. class CDataAdviseCache FAR* FAR* ppDataAdvCache);
  99. ~CDataAdviseCache();
  100. #ifdef _DEBUG
  101. HRESULT Dump(char **ppszDump, ULONG ulFlag, int nIndentLevel);
  102. // need to be able to access CDataAdviseCache private data members
  103. // in the following debugger extension APIs
  104. // this allows the debugger extension APIs to copy memory from the
  105. // debuggee process memory to the debugger's process memory
  106. // this is required since the Dump method follows pointers to other
  107. // structures and classes
  108. friend DEBUG_EXTENSION_API(dump_defobject);
  109. friend DEBUG_EXTENSION_API(dump_deflink);
  110. friend DEBUG_EXTENSION_API(dump_dataadvisecache);
  111. #endif // _DEBUG
  112. private:
  113. CDataAdviseCache();
  114. HRESULT ClientToDelegate(DWORD dwClient, DWORD FAR* pdwDelegate);
  115. LPDATAADVISEHOLDER m_pDAH; // a data advise holder
  116. CMapDwordDword m_mapClientToDelegate; // the map of clients to delegates
  117. };
  118. typedef class CDataAdviseCache DATAADVCACHE;
  119. typedef DATAADVCACHE FAR* LPDATAADVCACHE;
  120. #endif // _DACACHE_H_
  121.