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.

147 lines
3.1 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. regstate.h
  5. Abstract:
  6. This file contains declarations for data structures
  7. needed for maintaining state for registry key objects
  8. Author:
  9. Adam Edwards (adamed) 14-Nov-1997
  10. Notes:
  11. This file contains declarations for an object which
  12. can be stored in a collection. The collection is a linked
  13. list, whose most frequently accessed members are at the
  14. front of the list. Thus it is optimized for situations
  15. in which the same object may be asked for repeatedly.
  16. To use this list, you should create structures which
  17. inherit from the base object (StateObject). Each object
  18. has a key which must be specified when you create a new
  19. object. The key is used in searches and removes. The objects
  20. must all have disinct keys, but this is not enforced by the list --
  21. the caller should be sure to avoid duplicates.
  22. Note that the list does not allocate or free objects --
  23. it simply allows them to be added, removed, and searched
  24. for in the list. You will need to initialize any object
  25. before putting it into the list with the StateObjectInit
  26. function.
  27. --*/
  28. #ifdef LOCAL
  29. #if !defined(_REGSTATE_H_)
  30. #define _REGSTATE_H_
  31. //
  32. // Data types
  33. //
  34. //
  35. // StateObject
  36. //
  37. // This is the base type -- any object used with the list must
  38. // inherit from this object
  39. //
  40. typedef struct _StateObject
  41. {
  42. LIST_ENTRY Links;
  43. PVOID pvKey;
  44. } StateObject;
  45. //
  46. // Pointer type for a caller supplied function used to
  47. // destroy objects (de-allocate memory, free resources, etc)
  48. //
  49. typedef VOID (*PFNDestroyObject) (StateObject* pObject);
  50. //
  51. // StateObjectList
  52. //
  53. // This is a linked list of StateObjects, with the most frequently accessed
  54. // elements at the front of the list. If the same item is
  55. // accessed repeatedly, it is found immediately in search
  56. // operations. Note that the list is itself a StateObject, so
  57. // the list type can be composed with itself.
  58. //
  59. typedef struct _StateObjectList
  60. {
  61. StateObject Object;
  62. StateObject* pHead;
  63. } StateObjectList;
  64. //
  65. // Exported prototypes
  66. //
  67. //
  68. // Initializes a StateObject -- must be called before
  69. // the object is used
  70. //
  71. VOID StateObjectInit(
  72. StateObject* pObject,
  73. PVOID pvKey);
  74. //
  75. // Initializes a StateObjectList -- must be called before
  76. // the list is used
  77. //
  78. VOID StateObjectListInit(
  79. StateObjectList* pList,
  80. PVOID pvKey);
  81. //
  82. // Tells whether or not a list is empty
  83. //
  84. BOOL StateObjectListIsEmpty(StateObjectList* pList);
  85. //
  86. // Removes an object from the list
  87. //
  88. StateObject* StateObjectListRemove(
  89. StateObjectList* pList,
  90. PVOID pvKey);
  91. //
  92. // Finds an object in the list
  93. //
  94. StateObject* StateObjectListFind(
  95. StateObjectList* pList,
  96. PVOID pvKey);
  97. //
  98. // Adds an object to the list
  99. //
  100. VOID StateObjectListAdd(
  101. StateObjectList* pList,
  102. StateObject* pObject);
  103. //
  104. // Removes all objects from the list and
  105. // destroys them.
  106. //
  107. VOID StateObjectListClear(
  108. StateObjectList* pList,
  109. PFNDestroyObject pfnDestroy);
  110. #endif // _REGSTATE_H_
  111. #endif // LOCAL