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.

195 lines
4.7 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: GroupCon.h
  6. * Content: Group Connection Object Header File
  7. *@@BEGIN_MSINTERNAL
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 03/02/00 mjn Created
  12. * 05/05/00 mjn Added GetConnectionRef()
  13. * 08/15/00 mjn Added m_pGroup,SetGroup(),GetGroup()
  14. *@@END_MSINTERNAL
  15. *
  16. ***************************************************************************/
  17. #ifndef __GROUPCON_H__
  18. #define __GROUPCON_H__
  19. //**********************************************************************
  20. // Constant definitions
  21. //**********************************************************************
  22. #define VALID 0x0001
  23. //**********************************************************************
  24. // Macro definitions
  25. //**********************************************************************
  26. //**********************************************************************
  27. // Structure definitions
  28. //**********************************************************************
  29. class CConnection;
  30. class CNameTableEntry;
  31. typedef struct _DIRECTNETOBJECT DIRECTNETOBJECT;
  32. //**********************************************************************
  33. // Variable definitions
  34. //**********************************************************************
  35. //**********************************************************************
  36. // Function prototypes
  37. //**********************************************************************
  38. //**********************************************************************
  39. // Class prototypes
  40. //**********************************************************************
  41. // class for Group Connections
  42. class CGroupConnection
  43. {
  44. public:
  45. #undef DPF_MODNAME
  46. #define DPF_MODNAME "CGroupConnection::FPMAlloc"
  47. static BOOL FPMAlloc( void* pvItem, void* pvContext )
  48. {
  49. CGroupConnection* pGroupConn = (CGroupConnection*)pvItem;
  50. pGroupConn->m_Sig[0] = 'G';
  51. pGroupConn->m_Sig[1] = 'C';
  52. pGroupConn->m_Sig[2] = 'O';
  53. pGroupConn->m_Sig[3] = 'N';
  54. if (!DNInitializeCriticalSection(&pGroupConn->m_cs))
  55. {
  56. return(FALSE);
  57. }
  58. DebugSetCriticalSectionRecursionCount(&pGroupConn->m_cs,0);
  59. pGroupConn->m_bilink.Initialize();
  60. return(TRUE);
  61. };
  62. #undef DPF_MODNAME
  63. #define DPF_MODNAME "CGroupConnection::FPMInitialize"
  64. static void FPMInitialize( void* pvItem, void* pvContext )
  65. {
  66. CGroupConnection* pGroupConn = (CGroupConnection*)pvItem;
  67. pGroupConn->m_pdnObject = static_cast<DIRECTNETOBJECT*>(pvContext);
  68. pGroupConn->m_dwFlags = 0;
  69. pGroupConn->m_pConnection = NULL;
  70. pGroupConn->m_lRefCount = 1;
  71. pGroupConn->m_pGroup = NULL;
  72. DNASSERT(pGroupConn->m_bilink.IsEmpty());
  73. };
  74. #undef DPF_MODNAME
  75. #define DPF_MODNAME "CGroupConnection::FPMRelease"
  76. static void FPMRelease( void* pvItem )
  77. {
  78. const CGroupConnection* pGroupConn = (CGroupConnection*)pvItem;
  79. DNASSERT(pGroupConn->m_bilink.IsEmpty());
  80. };
  81. #undef DPF_MODNAME
  82. #define DPF_MODNAME "CGroupConnection::FPMDealloc"
  83. static void FPMDealloc( void* pvItem )
  84. {
  85. CGroupConnection* pGroupConn = (CGroupConnection*)pvItem;
  86. DNDeleteCriticalSection(&pGroupConn->m_cs);
  87. };
  88. void ReturnSelfToPool( void );
  89. #undef DPF_MODNAME
  90. #define DPF_MODNAME "CGroupConnection::AddRef"
  91. void AddRef(void)
  92. {
  93. DNASSERT(m_lRefCount > 0);
  94. DNInterlockedIncrement(const_cast<LONG*>(&m_lRefCount));
  95. };
  96. void Release(void);
  97. void Lock( void )
  98. {
  99. DNEnterCriticalSection(&m_cs);
  100. };
  101. void Unlock( void )
  102. {
  103. DNLeaveCriticalSection(&m_cs);
  104. };
  105. void AddToConnectionList( CBilink *const pBilink )
  106. {
  107. m_bilink.InsertBefore(pBilink);
  108. };
  109. void RemoveFromConnectionList( void )
  110. {
  111. m_bilink.RemoveFromList();
  112. };
  113. void SetConnection( CConnection *const pConnection );
  114. CConnection *GetConnection( void )
  115. {
  116. return(m_pConnection);
  117. };
  118. HRESULT GetConnectionRef( CConnection **const ppConnection );
  119. void SetGroup( CNameTableEntry *const pGroup );
  120. CNameTableEntry *GetGroup( void )
  121. {
  122. return( m_pGroup );
  123. };
  124. void MakeValid( void )
  125. {
  126. m_dwFlags |= VALID;
  127. };
  128. void MakeInvalid( void )
  129. {
  130. m_dwFlags &= (~VALID);
  131. };
  132. BOOL IsConnected( void ) const
  133. {
  134. if (m_pConnection != NULL)
  135. return(TRUE);
  136. return(FALSE);
  137. };
  138. CBilink m_bilink;
  139. private:
  140. BYTE m_Sig[4];
  141. DWORD volatile m_dwFlags;
  142. LONG volatile m_lRefCount;
  143. CConnection *m_pConnection;
  144. CNameTableEntry *m_pGroup;
  145. #ifndef DPNBUILD_ONLYONETHREAD
  146. DNCRITICAL_SECTION m_cs;
  147. #endif // !DPNBUILD_ONLYONETHREAD
  148. DIRECTNETOBJECT *m_pdnObject;
  149. };
  150. #undef DPF_MODNAME
  151. #endif // __GROUPCON_H__