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.

208 lines
4.2 KiB

  1. #ifndef _COMPONENT_H_
  2. #define _COMPONENT_H_
  3. #include <iostream.h>
  4. #include <windows.h>
  5. #include <setupapi.h>
  6. #include <stdio.h>
  7. #include <tchar.h>
  8. #include "logutils.h"
  9. #include "hcttools.h"
  10. const INT MaxStringSize = 256;
  11. const INT MaxBufferSize = 255;
  12. // Global variables
  13. static BOOL g_bUseLog;
  14. static BOOL g_bUseMsgBox;
  15. static BOOL g_bUseConsole;
  16. static BOOL g_bMasterInf;
  17. // Global function definitions
  18. VOID LogError(IN TCHAR *tszMsg,
  19. IN DWORD dwErrorLevel,
  20. IN TCHAR *tszFunctionName);
  21. // Some structures to hold temporary data
  22. typedef struct _DescAndTip{
  23. TCHAR tszDesc[MaxStringSize];
  24. TCHAR tszTip[MaxStringSize];
  25. }DescAndTip;
  26. class ComponentList;
  27. class RelationList;
  28. class Component{
  29. private:
  30. // ComponentId is the real ID
  31. TCHAR tszComponentId[MaxStringSize];
  32. // ParentId is the ID of the its parent
  33. // It is the same as its own ID if it is a
  34. // top level component
  35. TCHAR tszParentId[MaxStringSize];
  36. RelationList *prlNeedList;
  37. RelationList *prlExcludeList;
  38. RelationList *prlChildrenList;
  39. Component *Next;
  40. public:
  41. // Constructors and destructors
  42. Component();
  43. ~Component();
  44. Component(TCHAR *tszId);
  45. // Copy constructor
  46. Component(const Component& source);
  47. // Assignment operator
  48. const Component& operator=(const Component& source);
  49. // Get this component's ID
  50. TCHAR *GetComponentId(){
  51. return tszComponentId;
  52. }
  53. // Get this component's parent's ID
  54. TCHAR *GetParentId(){
  55. return tszParentId;
  56. }
  57. // Get a pointer to the parent component of this component
  58. // It returns NULL if this is a top-level component
  59. Component *GetParent(ComponentList *pclHead);
  60. RelationList *GetNeedList(){
  61. return prlNeedList;
  62. }
  63. RelationList *GetExcludeList(){
  64. return prlExcludeList;
  65. }
  66. RelationList *GetChildrenList(){
  67. return prlChildrenList;
  68. }
  69. // TRUE if this component is the parent of the parameter
  70. BOOL IsParent(Component *pcChild);
  71. // TRUE if this component is the child of the parameter
  72. BOOL IsChild(Component *pcParent);
  73. // TRUE if this component is needed by the parameter
  74. BOOL IsNeededBy(Component *pcComponent);
  75. // TRUE if this component is excluded by the parameter
  76. BOOL IsExcludeBy(Component *pcComponent);
  77. // The following function is to be called when only
  78. // the component ID is known
  79. BOOL BuildChildrenList(ComponentList *pclList);
  80. BOOL GetParentIdFromINF(HINF hinfHandle);
  81. BOOL IsTopLevelComponent();
  82. BOOL IsBottomComponent();
  83. BOOL IsNeededByOthers(ComponentList *pclList);
  84. BOOL IsExcludedByOthers(ComponentList *pclList);
  85. BOOL IsParentOfOthers();
  86. BOOL NeedAndExcludeAtSameTime(ComponentList *pclList);
  87. BOOL NeedOthers();
  88. BOOL ExcludeOthers();
  89. BOOL IsThereSameId(ComponentList *pclList);
  90. UINT GetDiskSpaceRequirement(HINF hinfHandle);
  91. // Doesn't matter if this is a public member
  92. // It will only be used once
  93. DescAndTip *pDescAndTip;
  94. BOOL IsThereSameDesc(ComponentList *pclList);
  95. BOOL HasSameParentWith(Component *pcComponent);
  96. friend class ComponentList;
  97. };
  98. class ComponentList{
  99. private:
  100. Component *pcHead;
  101. Component *pcCurrent;
  102. public:
  103. // Constructor and destructor
  104. ComponentList();
  105. ~ComponentList();
  106. void ResetList();
  107. Component *GetNext();
  108. BOOL Done();
  109. Component* AddComponent(TCHAR *tszId);
  110. BOOL RemoveComponent(TCHAR *tszId);
  111. Component *LookupComponent(TCHAR *tszId);
  112. friend class Component;
  113. };
  114. class Relation{
  115. TCHAR tszComponentId[MaxStringSize];
  116. Relation *Next;
  117. public:
  118. TCHAR *GetComponentId(){
  119. return tszComponentId;
  120. }
  121. friend class Component;
  122. friend class ComponentList;
  123. friend class RelationList;
  124. };
  125. class RelationList{
  126. Relation *prHead;
  127. Relation *prCurrent;
  128. public:
  129. RelationList();
  130. ~RelationList();
  131. void ResetList();
  132. BOOL Done();
  133. Relation *GetNext();
  134. Relation* AddRelation(TCHAR *tszId);
  135. BOOL RemoveRelation(TCHAR *tszId);
  136. friend class Component;
  137. friend class ComponentList;
  138. };
  139. #endif