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.

85 lines
1.3 KiB

  1. #ifndef _AUTOLISTCLASS_H_
  2. #define _AUTOLISTCLASS_H_
  3. class AutoListClass;
  4. extern AutoListClass *pALCHead;
  5. extern AutoListClass *pALCTail;
  6. extern int AutoListClassCount;
  7. class AutoListClass
  8. {
  9. protected:
  10. AutoListClass *pALCPrev;
  11. AutoListClass *pALCNext;
  12. public:
  13. AutoListClass(void)
  14. {
  15. if (pALCHead == NULL)
  16. {
  17. pALCHead = this;
  18. pALCTail = this;
  19. pALCPrev = NULL;
  20. pALCNext = NULL;
  21. }
  22. else // not empty
  23. {
  24. AutoListClass *curr;
  25. curr = pALCTail;
  26. curr->pALCNext = this;
  27. pALCPrev = curr;
  28. pALCTail = this;
  29. pALCNext = NULL;
  30. }
  31. AutoListClassCount++;
  32. }
  33. ~AutoListClass()
  34. {
  35. if (pALCHead == this)
  36. pALCHead = pALCNext;
  37. if (pALCTail == this)
  38. pALCTail = pALCPrev;
  39. if (pALCNext != NULL)
  40. pALCNext->pALCPrev = pALCPrev;
  41. if (pALCPrev != NULL)
  42. pALCPrev->pALCNext = pALCNext;
  43. // just in case clean up
  44. pALCNext = NULL;
  45. pALCPrev = NULL;
  46. AutoListClassCount--;
  47. }
  48. AutoListClass * GetNext (void)
  49. {
  50. return pALCNext;
  51. }
  52. AutoListClass * GetPrev (void)
  53. {
  54. return pALCPrev;
  55. }
  56. static AutoListClass * GetHead (void)
  57. {
  58. return pALCHead;
  59. }
  60. static AutoListClass * GetTail (void)
  61. {
  62. return pALCTail;
  63. }
  64. static int ALCCount (void)
  65. {
  66. return AutoListClassCount;
  67. }
  68. };
  69. #endif