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.

211 lines
4.3 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. bool lookDefunct = false);
  61. SchemaObject* LookupSchemaObjectByCN( LPCTSTR pszCN,
  62. SchmMgmtObjectType objectType );
  63. VOID ReleaseRef( SchemaObject* pObject );
  64. //
  65. // Load and reload.
  66. //
  67. HRESULT LoadCache( VOID );
  68. HRESULT ProcessSearchResults( IDirectorySearch *pDSSearch,
  69. ADS_SEARCH_HANDLE hSearchHandle,
  70. SchmMgmtObjectType ObjectType );
  71. VOID InsertSortedTail( SchemaObject* pObject );
  72. ListEntry* MakeColumnList( PADS_SEARCH_COLUMN pColumn );
  73. VOID FreeColumnList( ListEntry *pListHead );
  74. VOID FreeAll( );
  75. //
  76. // The scope control that this is the cache for.
  77. //
  78. VOID SetScopeControl( ComponentData *pScope ) {
  79. pScopeControl = pScope;
  80. }
  81. //
  82. // Has the schema been loaded
  83. //
  84. BOOLEAN IsSchemaLoaded() { return fInitialized; }
  85. ComponentData *pScopeControl;
  86. };
  87. class SchemaObject {
  88. private:
  89. public:
  90. //
  91. // The hash chain variable.
  92. //
  93. SchemaObject* pNext;
  94. SchemaObject* pSortedListFlink;
  95. SchemaObject* pSortedListBlink;
  96. //
  97. // Constructors.
  98. //
  99. SchemaObject();
  100. ~SchemaObject();
  101. //
  102. // The common object information.
  103. // The ldap display name is the hash key.
  104. //
  105. CString ldapDisplayName;
  106. CString commonName;
  107. CString description;
  108. //
  109. // If this is an object that we have added, it
  110. // will have an oid here and we should refer to
  111. // the object by its oid since that is the only
  112. // way we can guarantee that the ds will know
  113. // the object.
  114. //
  115. CString oid;
  116. //
  117. // If this object is defunct, do not show it in the
  118. // classes or attributes select box!
  119. //
  120. BOOL isDefunct;
  121. SchmMgmtObjectType schemaObjectType;
  122. //
  123. // Class object specific data for the cache.
  124. //
  125. DWORD dwClassType;
  126. ListEntry *systemMayContain;
  127. ListEntry *mayContain;
  128. ListEntry *systemMustContain;
  129. ListEntry *mustContain;
  130. ListEntry *systemAuxiliaryClass;
  131. ListEntry *auxiliaryClass;
  132. CString subClassOf;
  133. //
  134. // Attribute object specific data for the cache.
  135. //
  136. UINT SyntaxOrdinal;
  137. };
  138. class ListEntry {
  139. private:
  140. public:
  141. ListEntry *pNext;
  142. CString Attribute;
  143. ListEntry() { pNext = NULL; }
  144. ~ListEntry() { ; }
  145. };
  146. #endif