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.

148 lines
4.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: mrshlist.hxx
  7. //
  8. // Contents: CMarshalList header
  9. //
  10. // Classes: CMarshalList
  11. //
  12. // History: 16-Mar-96 HenryLee Created
  13. //
  14. //----------------------------------------------------------------------------
  15. #ifndef __MRSHLIST_HXX__
  16. #define __MRSHLIST_HXX__
  17. #define POINTER_IDENTITY
  18. class CMarshalList; // forward declaration for SAFE macro
  19. SAFE_DFBASED_PTR(CBasedMarshalListPtr, CMarshalList);
  20. //+---------------------------------------------------------------------------
  21. //
  22. // Class: CMarshalList (ml)
  23. //
  24. // Purpose: Maintains a list of marshaled exposed objects that
  25. // represent the same storage or stream
  26. //
  27. // Interface: See below
  28. //
  29. // Notes: This class is intended to solve the "pointer identity"
  30. // problem. When an IStorage or IStream is passed as an
  31. // [in, out] RPC parameter, two marshal/unmarshalings occur,
  32. // one for the [in] side, and a reverse marshaling for
  33. // the [out] side. The previous algorithm always allocated
  34. // a new exposed object for every unmarshaling, so the
  35. // pointer going into an [in,out] call isn't the same
  36. // as the pointer returned from the call.
  37. //
  38. // This algorithm links the exposed objects together, each
  39. // link keyed by the ContextId (ProcessId). When unmarshaling,
  40. // this list is checked for a valid exposed object that
  41. // can be reused. If not, then a new exposed object
  42. // is allocated and inserted into the linked list.
  43. // Instances of this class must live in shared memory
  44. // in order for the list to traverse across processes
  45. //
  46. // History: 26-Mar-96 HenryLee Created
  47. //
  48. //----------------------------------------------------------------------------
  49. class CMarshalList
  50. {
  51. protected:
  52. inline CMarshalList ();
  53. inline ~CMarshalList ();
  54. public:
  55. inline CMarshalList * GetNextMarshal () const;
  56. inline void SetNextMarshal (CMarshalList *pml);
  57. inline ContextId GetContextId () const;
  58. CMarshalList * FindMarshal (ContextId ctxid) const;
  59. void AddMarshal (CMarshalList *pml);
  60. void RemoveMarshal (CMarshalList *pml);
  61. private:
  62. CBasedMarshalListPtr _pmlNext;
  63. ContextId _cntxid;
  64. };
  65. //+---------------------------------------------------------------------------
  66. //
  67. // Member: CMarshalList::CMarshalList, public
  68. //
  69. // Synopsis: Constructor
  70. //
  71. // History: 17-Mar-96 HenryLee Created
  72. //
  73. //----------------------------------------------------------------------------
  74. inline CMarshalList::CMarshalList ()
  75. {
  76. _pmlNext = P_TO_BP(CBasedMarshalListPtr, this);
  77. _cntxid = GetCurrentContextId();
  78. }
  79. //+---------------------------------------------------------------------------
  80. //
  81. // Member: CMarshalList::~CMarshalList, public
  82. //
  83. // Synopsis: Destructor
  84. //
  85. // History: 17-Mar-96 HenryLee Created
  86. //
  87. //----------------------------------------------------------------------------
  88. inline CMarshalList::~CMarshalList ()
  89. {
  90. RemoveMarshal(this);
  91. }
  92. //+---------------------------------------------------------------------------
  93. //
  94. // Member: CMarshalList::GetNext, public
  95. //
  96. // Synopsis: Returns the next element of the list
  97. //
  98. // History: 17-Mar-96 HenryLee Created
  99. //
  100. //----------------------------------------------------------------------------
  101. inline CMarshalList *CMarshalList::GetNextMarshal () const
  102. {
  103. return BP_TO_P(CMarshalList *, _pmlNext);
  104. }
  105. //+---------------------------------------------------------------------------
  106. //
  107. // Member: CMarshalList::SetNext, public
  108. //
  109. // Synopsis: Assigns the next element of the list
  110. //
  111. // History: 17-Mar-96 HenryLee Created
  112. //
  113. //----------------------------------------------------------------------------
  114. inline void CMarshalList::SetNextMarshal (CMarshalList *pml)
  115. {
  116. _pmlNext = P_TO_BP(CBasedMarshalListPtr, pml);
  117. }
  118. //+---------------------------------------------------------------------------
  119. //
  120. // Member: CMarshalList::GetContextId, public
  121. //
  122. // Synopsis: Returns the context id of the current element
  123. //
  124. // History: 17-Mar-96 HenryLee Created
  125. //
  126. //----------------------------------------------------------------------------
  127. inline ContextId CMarshalList::GetContextId () const
  128. {
  129. return _cntxid;
  130. }
  131. #endif // #ifndef __MRSHLIST_HXX__