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.

110 lines
2.5 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2001, Microsoft Corporation All rights reserved.
  4. //
  5. // Module Name:
  6. //
  7. // ComponentList.h
  8. //
  9. // Abstract:
  10. //
  11. // This file contains the Component List object definition.
  12. //
  13. // Revision History:
  14. //
  15. // 2001-06-20 lguindon Created.
  16. //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. #ifndef _COMPONENTLIST_H_
  19. #define _COMPONENTLIST_H_
  20. ///////////////////////////////////////////////////////////////////////////////
  21. //
  22. // Includes Files.
  23. //
  24. ///////////////////////////////////////////////////////////////////////////////
  25. #include "infparser.h"
  26. #include "Component.h"
  27. ///////////////////////////////////////////////////////////////////////////////
  28. //
  29. // Class definition.
  30. //
  31. ///////////////////////////////////////////////////////////////////////////////
  32. class ComponentList
  33. {
  34. public:
  35. ComponentList()
  36. {
  37. m_Head = NULL;
  38. m_Tail = NULL;
  39. m_Entries = 0;
  40. };
  41. ~ComponentList()
  42. {
  43. Component* temp;
  44. while ((temp = getFirst()) != NULL)
  45. {
  46. remove(temp);
  47. }
  48. };
  49. DWORD getComponentNumber() { return (m_Entries); };
  50. Component* getFirst() { return (m_Head); };
  51. void add(Component* item)
  52. {
  53. if ((m_Tail == NULL) && (m_Head == NULL))
  54. {
  55. m_Tail = item;
  56. m_Head = item;
  57. }
  58. else
  59. {
  60. item->setPrevious(m_Tail);
  61. m_Tail->setNext(item);
  62. m_Tail = item;
  63. }
  64. m_Entries++;
  65. };
  66. void remove(Component* item)
  67. {
  68. if ((m_Tail == m_Head) && (m_Tail == item))
  69. {
  70. m_Tail = NULL;
  71. m_Head = NULL;
  72. }
  73. else
  74. {
  75. if (m_Head = item)
  76. {
  77. m_Head = item->getNext();
  78. (item->getNext())->setPrevious(NULL);
  79. }
  80. else if (m_Tail = item)
  81. {
  82. m_Tail = item->getPrevious();
  83. (item->getPrevious())->setNext(NULL);
  84. }
  85. else
  86. {
  87. (item->getPrevious())->setNext(item->getNext());
  88. (item->getNext())->setPrevious(item->getPrevious());
  89. }
  90. }
  91. delete item;
  92. item = NULL;
  93. m_Entries--;
  94. };
  95. private:
  96. Component *m_Head;
  97. Component *m_Tail;
  98. DWORD m_Entries;
  99. };
  100. #endif //_COMPONENTLIST_H_