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.

210 lines
4.1 KiB

  1. /****
  2. Cache.h
  3. CoryWest@Microsoft.Com
  4. The schema caching routines to improve browsing performance.
  5. Copyright July 1997, Microsoft Corporation
  6. ****/
  7. #include "nodetype.h"
  8. #ifndef __CACHE_H_INCLUDED__
  9. #define __CACHE_H_INCLUDED__
  10. //
  11. // The schema class objects.
  12. //
  13. #define HASH_TABLE_SIZE 1000
  14. class SchemaObject;
  15. class ListEntry;
  16. class SchemaObjectCache {
  17. //
  18. // We let certain routines walk the hash table
  19. // to populate the list views.
  20. //
  21. friend class Component;
  22. friend class ComponentData;
  23. friend class CSchmMgmtSelect;
  24. friend class ClassGeneralPage;
  25. friend HRESULT StringListToColumnList(
  26. ComponentData* pScopeControl,
  27. CStringList& refstringlist,
  28. ListEntry **ppNewList );
  29. private:
  30. //
  31. // A rudimentary hash table with no resizing.
  32. //
  33. BOOLEAN fInitialized;
  34. UINT buckets;
  35. SchemaObject** hash_table;
  36. UINT CalculateHashKey( CString HashKey );
  37. //
  38. // The server sorted lists of elements.
  39. //
  40. SchemaObject* pSortedClasses;
  41. SchemaObject* pSortedAttribs;
  42. public:
  43. //
  44. // Initialize and cleanup the cache.
  45. //
  46. SchemaObjectCache();
  47. ~SchemaObjectCache();
  48. //
  49. // Access routines. ReleaseRef() must be called after every
  50. // LookupSchemaObject when the caller is done with the the
  51. // SchemaObject pointer.
  52. //
  53. // LookupSchemaObject takes an object type because there
  54. // may be a class and an attribute with the same ldapDisplayName.
  55. //
  56. HRESULT InsertSchemaObject( SchemaObject* Object );
  57. HRESULT InsertSortedSchemaObject( SchemaObject *Object );
  58. SchemaObject* LookupSchemaObject( CString ldapDisplayName,
  59. SchmMgmtObjectType ObjectType );
  60. SchemaObject* LookupSchemaObjectByCN( LPCTSTR pszCN,
  61. SchmMgmtObjectType objectType );
  62. VOID ReleaseRef( SchemaObject* pObject );
  63. //
  64. // Load and reload.
  65. //
  66. HRESULT LoadCache( VOID );
  67. HRESULT ProcessSearchResults( IDirectorySearch *pDSSearch,
  68. ADS_SEARCH_HANDLE hSearchHandle,
  69. SchmMgmtObjectType ObjectType );
  70. VOID InsertSortedTail( SchemaObject* pObject );
  71. ListEntry* MakeColumnList( PADS_SEARCH_COLUMN pColumn );
  72. VOID FreeColumnList( ListEntry *pListHead );
  73. VOID FreeAll( );
  74. //
  75. // The scope control that this is the cache for.
  76. //
  77. VOID SetScopeControl( ComponentData *pScope ) {
  78. pScopeControl = pScope;
  79. }
  80. //
  81. // Has the schema been loaded
  82. //
  83. BOOLEAN IsSchemaLoaded() { return fInitialized; }
  84. ComponentData *pScopeControl;
  85. };
  86. class SchemaObject {
  87. private:
  88. public:
  89. //
  90. // The hash chain variable.
  91. //
  92. SchemaObject* pNext;
  93. SchemaObject* pSortedListFlink;
  94. SchemaObject* pSortedListBlink;
  95. //
  96. // Constructors.
  97. //
  98. SchemaObject();
  99. ~SchemaObject();
  100. //
  101. // The common object information.
  102. // The ldap display name is the hash key.
  103. //
  104. CString ldapDisplayName;
  105. CString commonName;
  106. CString description;
  107. //
  108. // If this is an object that we have added, it
  109. // will have an oid here and we should refer to
  110. // the object by its oid since that is the only
  111. // way we can guarantee that the ds will know
  112. // the object.
  113. //
  114. CString oid;
  115. //
  116. // If this object is defunct, do not show it in the
  117. // classes or attributes select box!
  118. //
  119. BOOL isDefunct;
  120. SchmMgmtObjectType schemaObjectType;
  121. //
  122. // Class object specific data for the cache.
  123. //
  124. DWORD dwClassType;
  125. ListEntry *systemMayContain;
  126. ListEntry *mayContain;
  127. ListEntry *systemMustContain;
  128. ListEntry *mustContain;
  129. ListEntry *systemAuxiliaryClass;
  130. ListEntry *auxiliaryClass;
  131. CString subClassOf;
  132. //
  133. // Attribute object specific data for the cache.
  134. //
  135. UINT SyntaxOrdinal;
  136. };
  137. class ListEntry {
  138. private:
  139. public:
  140. ListEntry *pNext;
  141. CString Attribute;
  142. ListEntry() { pNext = NULL; }
  143. ~ListEntry() { ; }
  144. };
  145. #endif