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.

334 lines
6.6 KiB

  1. /**MOD+**********************************************************************/
  2. /* Module: objs.cpp */
  3. /* */
  4. /* Purpose: Client object container class */
  5. /* */
  6. /* Copyright(C) Microsoft Corporation 1997 */
  7. /* */
  8. /****************************************************************************/
  9. #include <adcg.h>
  10. #define TRC_GROUP TRC_GROUP_CORE
  11. #define TRC_FILE "objs"
  12. extern "C" {
  13. #include <adcgdata.h>
  14. #include <atrcapi.h>
  15. }
  16. #include "objs.h"
  17. #include "wui.h"
  18. #include "autil.h"
  19. #include "aco.h"
  20. #include "snd.h"
  21. #include "cd.h"
  22. #include "rcv.h"
  23. #include "cc.h"
  24. #include "ih.h"
  25. #include "or.h"
  26. #include "fs.h"
  27. #include "sl.h"
  28. #include "nl.h"
  29. #include "nc.h"
  30. #include "mcs.h"
  31. #include "clicense.h"
  32. #include "xt.h"
  33. #include "td.h"
  34. #include "cm.h"
  35. #include "uh.h"
  36. #include "gh.h"
  37. #include "od.h"
  38. #include "op.h"
  39. #include "sp.h"
  40. #include "clx.h"
  41. #include "cchan.h"
  42. CObjs::CObjs()
  43. {
  44. DC_MEMSET(this, 0, sizeof(CObjs));
  45. _dwActiveObjects = 0;
  46. _cRefCount = 0;
  47. _pCoObject = new CCO(this);
  48. _pUtObject = new CUT();
  49. _pCdObject = new CCD(this);
  50. _pSndObject = new CSND(this);
  51. _pRcvObject = new CRCV(this);
  52. _pCcObject = new CCC(this);
  53. _pIhObject = new CIH(this);
  54. _pOrObject = new COR(this);
  55. _pFsObject = new CFS(this);
  56. _pSlObject = new CSL(this);
  57. _pNlObject = new CNL(this);
  58. _pNcObject = new CNC(this);
  59. _pMCSObject = new CMCS(this);
  60. _pLicObject = new CLic(this);
  61. _pChanObject = new CChan(this);
  62. _pXTObject = new CXT(this);
  63. _pTDObject = new CTD(this);
  64. _pCMObject = new CCM(this);
  65. _pUHObject = new CUH(this);
  66. _pGHObject = new CGH(this);
  67. _pODObject = new COD(this);
  68. _pOPObject = new COP(this);
  69. _pSPObject = new CSP(this);
  70. _pCLXObject = new CCLX(this);
  71. }
  72. //
  73. // Consistency check..returns FALSE
  74. // if any of the object pointers are not set
  75. //
  76. BOOL CObjs::CheckPointers()
  77. {
  78. DC_BEGIN_FN("CheckPointers");
  79. if(!_pCoObject)
  80. {
  81. TRC_ERR((TB,_T("_pCoObject NULL")));
  82. return FALSE;
  83. }
  84. if(!_pUtObject)
  85. {
  86. TRC_ERR((TB,_T("_pUtObject NULL")));
  87. return FALSE;
  88. }
  89. if(!_pCdObject)
  90. {
  91. TRC_ERR((TB,_T("_pCdObject NULL")));
  92. return FALSE;
  93. }
  94. if(!_pSndObject)
  95. {
  96. TRC_ERR((TB,_T("_pSndObject NULL")));
  97. return FALSE;
  98. }
  99. if(!_pRcvObject)
  100. {
  101. TRC_ERR((TB,_T("_pRcvObject NULL")));
  102. return FALSE;
  103. }
  104. if(!_pCcObject)
  105. {
  106. TRC_ERR((TB,_T("_pCcObject NULL")));
  107. return FALSE;
  108. }
  109. if(!_pIhObject)
  110. {
  111. TRC_ERR((TB,_T("_pIhObject NULL")));
  112. return FALSE;
  113. }
  114. if(!_pOrObject)
  115. {
  116. TRC_ERR((TB,_T("_pOrObject NULL")));
  117. return FALSE;
  118. }
  119. if(!_pFsObject)
  120. {
  121. TRC_ERR((TB,_T("_pFsObject NULL")));
  122. return FALSE;
  123. }
  124. if(!_pSlObject)
  125. {
  126. TRC_ERR((TB,_T("_pSlObject NULL")));
  127. return FALSE;
  128. }
  129. if(!_pNlObject)
  130. {
  131. TRC_ERR((TB,_T("_pNlObject NULL")));
  132. return FALSE;
  133. }
  134. if(!_pNcObject)
  135. {
  136. TRC_ERR((TB,_T("_pNcObject NULL")));
  137. return FALSE;
  138. }
  139. if(!_pMCSObject)
  140. {
  141. TRC_ERR((TB,_T("_pMCSObject NULL")));
  142. return FALSE;
  143. }
  144. if(!_pLicObject)
  145. {
  146. TRC_ERR((TB,_T("_pLicObject NULL")));
  147. return FALSE;
  148. }
  149. if(!_pChanObject)
  150. {
  151. TRC_ERR((TB,_T("_pChanObject NULL")));
  152. return FALSE;
  153. }
  154. if(!_pXTObject)
  155. {
  156. TRC_ERR((TB,_T("_pXTObject NULL")));
  157. return FALSE;
  158. }
  159. if(!_pTDObject)
  160. {
  161. TRC_ERR((TB,_T("_pTDObject NULL")));
  162. return FALSE;
  163. }
  164. if(!_pCMObject)
  165. {
  166. TRC_ERR((TB,_T("_pCMObject NULL")));
  167. return FALSE;
  168. }
  169. if(!_pUHObject)
  170. {
  171. TRC_ERR((TB,_T("_pUHObject NULL")));
  172. return FALSE;
  173. }
  174. if(!_pGHObject)
  175. {
  176. TRC_ERR((TB,_T("_pGHObject NULL")));
  177. return FALSE;
  178. }
  179. if(!_pODObject)
  180. {
  181. TRC_ERR((TB,_T("_pODObject NULL")));
  182. return FALSE;
  183. }
  184. if(!_pOPObject)
  185. {
  186. TRC_ERR((TB,_T("_pODObject NULL")));
  187. return FALSE;
  188. }
  189. if(!_pSPObject)
  190. {
  191. TRC_ERR((TB,_T("_pSPObject NULL")));
  192. return FALSE;
  193. }
  194. if(!_pCLXObject)
  195. {
  196. TRC_ERR((TB,_T("_pCLXObject NULL")));
  197. return FALSE;
  198. }
  199. DC_END_FN();
  200. return TRUE;
  201. }
  202. CObjs::~CObjs()
  203. {
  204. delete _pCoObject;
  205. delete _pUtObject;
  206. delete _pCdObject;
  207. delete _pSndObject;
  208. delete _pRcvObject;
  209. delete _pCcObject;
  210. delete _pIhObject;
  211. delete _pOrObject;
  212. delete _pFsObject;
  213. delete _pSlObject;
  214. delete _pNlObject;
  215. delete _pNcObject;
  216. delete _pMCSObject;
  217. delete _pLicObject;
  218. delete _pChanObject;
  219. delete _pXTObject;
  220. delete _pTDObject;
  221. delete _pCMObject;
  222. delete _pUHObject;
  223. delete _pGHObject;
  224. delete _pODObject;
  225. delete _pOPObject;
  226. delete _pSPObject;
  227. delete _pCLXObject;
  228. DC_MEMSET(this, 0, sizeof(CObjs));
  229. }
  230. //
  231. // Add a reference, flagging which object holds
  232. // a reference
  233. //
  234. LONG CObjs::AddObjReference(DWORD dwFlag)
  235. {
  236. _dwActiveObjects |= dwFlag;
  237. return AddRef();
  238. }
  239. //
  240. // Add a reference, flagging which object release
  241. // the reference
  242. //
  243. LONG CObjs::ReleaseObjReference(DWORD dwFlag)
  244. {
  245. _dwActiveObjects &= ~dwFlag;
  246. return Release();
  247. }
  248. //
  249. // Simple Addref
  250. //
  251. LONG CObjs::AddRef()
  252. {
  253. return InterlockedIncrement(&_cRefCount);
  254. }
  255. //
  256. // Simple release
  257. // Does not delete on refcount == 0
  258. // this is simply for debugging purposes
  259. //
  260. LONG CObjs::Release()
  261. {
  262. DC_BEGIN_FN("Release");
  263. LONG ref = InterlockedDecrement(&_cRefCount);
  264. TRC_ASSERT(ref >= 0, (TB,_T("refcount when below zero %d"), ref));
  265. DC_END_FN();
  266. return ref;
  267. }
  268. //
  269. // Checks if there are any active references
  270. // returns true if yes
  271. BOOL CObjs::CheckActiveReferences()
  272. {
  273. if(_cRefCount || _dwActiveObjects)
  274. {
  275. return TRUE;
  276. }
  277. else
  278. {
  279. return FALSE;
  280. }
  281. }