Source code of Windows XP (NT5)
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.

226 lines
6.1 KiB

  1. // sequence.h: interface for the class sequencing.
  2. // Copyright (c)1997-2001 Microsoft Corporation
  3. //
  4. //////////////////////////////////////////////////////////////////////
  5. #if _MSC_VER >= 1000
  6. #pragma once
  7. #endif // _MSC_VER >= 1000
  8. #include "precomp.h"
  9. #include "sceprov.h"
  10. #include "GenericClass.h"
  11. using namespace std;
  12. #include <list>
  13. //=======================================================================
  14. /*
  15. Class description
  16. Naming:
  17. CNameList stands for Names List.
  18. Base class:
  19. None.
  20. Purpose of class:
  21. (1) A simple wrapper to get rid of the burden of releasing
  22. memories of the list of string
  23. Design:
  24. (1) Just a non-trivial destructor.
  25. Use:
  26. (1) Obvious.
  27. */
  28. class CNameList
  29. {
  30. public:
  31. ~CNameList();
  32. vector<LPWSTR> m_vList;
  33. };
  34. //=======================================================================
  35. /*
  36. Class description
  37. Naming:
  38. COrderNameList stands Ordered (by priority) Names List.
  39. Base class:
  40. None.
  41. Purpose of class:
  42. (1) To support class sequencing. Classes need to be put in a particular
  43. order when we spawn them to execute methods. They may have dependencies.
  44. To support a flexible ordering of classes, we use several classes. This
  45. is the most important one.
  46. Design:
  47. (1) To support sequencing classes, we have developed a mechanism that allows
  48. certain classes to have the same priority. Within the same priority,
  49. the classes names are again ordered. Priorities are DWORD numbers. The smaller
  50. the numeric value is, the higher the priority.
  51. (2) To manage this list within list structure, we use map (m_mapPriNames)
  52. mapping from priority to a CNameList. That map allows us to quickly lookup
  53. the names list for a given priority.
  54. (3) All existing priorities are managed by a vector m_listPriority.
  55. (4) Names in the lower priority has overall lower priority in the sequence of classes.
  56. Use:
  57. (1) To create a new order name list, you call BeginCreation followed by a
  58. serious of CreateOrderList calls. When all such list info are parsed and you have
  59. finished the creation process, then you call EndCreation.
  60. (2) To start enumerating the ordered name list, you first call GetNext
  61. with *pdwEnumHandle = 0. This *pdwEnumHandle becomes your next GetNext's
  62. input parameter.
  63. */
  64. class COrderNameList
  65. {
  66. public:
  67. COrderNameList();
  68. ~COrderNameList();
  69. void BeginCreation()
  70. {
  71. Cleanup();
  72. }
  73. HRESULT CreateOrderList (
  74. DWORD dwPriority,
  75. LPCWSTR pszListInfo
  76. );
  77. HRESULT EndCreation();
  78. HRESULT GetNext (
  79. const CNameList** ppList,
  80. DWORD* pdwEnumHandle
  81. )const;
  82. private:
  83. void Cleanup();
  84. typedef map<DWORD, CNameList* > MapPriorityToNames;
  85. typedef MapPriorityToNames::iterator PriToNamesIter;
  86. typedef list<DWORD> PriorityList;
  87. typedef PriorityList::iterator ListIter;
  88. MapPriorityToNames m_mapPriNames;
  89. PriorityList m_listPriority;
  90. CNameList** m_ppList;
  91. };
  92. //=======================================================================
  93. /*
  94. Class description
  95. Naming:
  96. CSequencer stands for sequencing object.
  97. Base class:
  98. None.
  99. Purpose of class:
  100. (1) When we execute a method on a store, the order objects are created for the
  101. execution is of great importance. For all Sce core objects, the engine takes
  102. over control. But for extension classes, we must build a flexible ordering
  103. mechanism. This is the out-most layer for this implementation.
  104. Design:
  105. (1) We can create ourself.
  106. (2) After creation, caller can call to get a non-modifiable COrderNameList to serve
  107. the ordering need.
  108. Use:
  109. (1) Create an instance of this class.
  110. (2) Call Create to populate its contents.
  111. (3) Call GetOrderList, caller gets the access to the ordered name list.
  112. */
  113. class CSequencer
  114. {
  115. public:
  116. HRESULT GetOrderList(const COrderNameList** pList);
  117. HRESULT Create(IWbemServices* pNamespace, LPCWSTR pszStore, LPCWSTR pszMethod);
  118. private:
  119. COrderNameList m_ClassList;
  120. };
  121. //=======================================================================
  122. /*
  123. Class description
  124. Naming:
  125. CClassOrder stands for Classes Order.
  126. Base class:
  127. CGenericClass, because it is a class representing a WMI
  128. object - its WMI class name is Sce_AuditPolicy
  129. Purpose of class:
  130. (1) Certain template may want to have its own ordering. This class implements
  131. our WMI class Sce_ClassOrder for per-template class sequencing.
  132. Design:
  133. (1) it implements all pure virtual functions declared in CGenericClass
  134. so that it is a concrete class to create.
  135. (2) Since it has virtual functions, the desctructor should be virtual.
  136. (3) Per-tempalte sequencing takes precedence over namespace-wise class
  137. sequencing.
  138. Use:
  139. (1) We probably will never directly use this class. All its use is driven by
  140. CGenericClass's interface (its virtual functions).
  141. */
  142. class CClassOrder : public CGenericClass
  143. {
  144. public:
  145. CClassOrder (
  146. ISceKeyChain *pKeyChain,
  147. IWbemServices *pNamespace,
  148. IWbemContext *pCtx
  149. );
  150. virtual ~CClassOrder();
  151. public:
  152. virtual HRESULT PutInst (
  153. IWbemClassObject *pInst,
  154. IWbemObjectSink *pHandler,
  155. IWbemContext *pCtx
  156. );
  157. virtual HRESULT CreateObject (
  158. IWbemObjectSink *pHandler,
  159. ACTIONTYPE atAction
  160. );
  161. private:
  162. };