Source code of Windows XP (NT5)
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.

143 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. coid.hxx
  5. Abstract:
  6. CClientOid objects represent OIDs referenced by one of more processes on
  7. this machine running as the same user.
  8. Author:
  9. Mario Goertzel [MarioGo]
  10. Revision History:
  11. MarioGo 04-08-95 Bits 'n pieces
  12. MarioGo 12-21-95 Rewrite - OIDs are not universally unique
  13. --*/
  14. #ifndef __COID_HXX
  15. #define __COID_HXX
  16. class CClientOid : public CId3TableElement
  17. /*++
  18. Class Description:
  19. Each instance of this class represtents an object being
  20. used on this or another machine by a one or more processes
  21. owned by a particular local identity on this machine.
  22. Members:
  23. _pOxid - Pointer to the OXID exporting this OID
  24. _pSet - Pointer to the set which owns this OID
  25. _cClients - The number of client processes actually
  26. using this object.
  27. Note: This value may only be changed with the
  28. client lock held exclusively.
  29. Note, also, that the set will not release its
  30. reference unless this value is zero. The
  31. effective reference count is _references
  32. + _cClients.
  33. REVIEW: We could write our own Reference
  34. and Release methods. Then the client
  35. set could delete (rather then Release()) the
  36. oids directly.
  37. _fIn:1 - A flag to indicate whether this object has
  38. already been added to the remote set.
  39. --*/
  40. {
  41. private :
  42. CClientOxid *_pOxid;
  43. CClientSet *_pSet;
  44. DWORD _cClients;
  45. BOOL _fIn:1; // Is this OID in the remote set.
  46. public :
  47. CClientOid(ID &oid,
  48. ID &mid,
  49. CToken *pToken,
  50. CClientOxid *pOxid,
  51. CClientSet *pSet) :
  52. CId3TableElement(oid, mid, pToken),
  53. _pOxid(pOxid),
  54. _pSet(pSet),
  55. _fIn(FALSE),
  56. _cClients(1)
  57. {
  58. // Token is held by the set which we reference,
  59. // no need for us to reference it ourself.
  60. _pOxid->Reference();
  61. _pSet->Reference();
  62. }
  63. ~CClientOid();
  64. BOOL In()
  65. {
  66. return(_fIn);
  67. }
  68. void Added()
  69. {
  70. ASSERT(gpClientLock->HeldExclusive());
  71. _fIn = TRUE;
  72. }
  73. void Deleted()
  74. {
  75. ASSERT(gpClientLock->HeldExclusive());
  76. _fIn = FALSE;
  77. }
  78. void ClientReference()
  79. {
  80. ASSERT(gpClientLock->HeldExclusive());
  81. _cClients++;
  82. if (_cClients == 1)
  83. {
  84. // Rereferenced.
  85. _pSet->ObjectUpdate(this);
  86. }
  87. }
  88. void
  89. ClientRelease()
  90. {
  91. ASSERT(gpClientLock->HeldExclusive());
  92. _cClients--;
  93. if (_cClients == 0)
  94. {
  95. // Not referenced
  96. _pSet->ObjectUpdate(this); // May release this.
  97. }
  98. // This pointer maybe invalid.
  99. }
  100. BOOL Out() {
  101. return(_cClients == 0);
  102. }
  103. inline CClientOxid* GetClientOxid()
  104. {
  105. return _pOxid;
  106. }
  107. };
  108. #endif // __COID_HXX