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
5.4 KiB

  1. /*++
  2. Copyright (C) 1996-2000 Microsoft Corporation
  3. Module Name:
  4. DBREP.H
  5. Abstract:
  6. Object database class representations which are stored in the database.
  7. History:
  8. --*/
  9. #ifndef _DBREP_H_
  10. #define _DBREP_H_
  11. #include <stdio.h>
  12. #include <wbemcli.h>
  13. #include <TIME.H>
  14. #include "MMFArena2.h"
  15. #include "dbavl.h"
  16. #include "dbarry.h"
  17. #include <wbemutil.h>
  18. extern CMMFArena2* g_pDbArena;
  19. struct NSREP;
  20. struct CLASSDEF;
  21. struct INSTDEF;
  22. struct RepCollectionItem;
  23. struct RepCollection;
  24. struct PtrCollection;
  25. struct SINDEXTABLE;
  26. struct DANGREF;
  27. struct DANGREFCLASS;
  28. struct DANGREFKEY;
  29. struct DANGLREFSCHEMA;
  30. struct DANGREFSCHEMA;
  31. struct DANGREFSCHEMACLASS;
  32. struct DBROOT;
  33. class DATABASE_CRITICAL_ERROR : public CX_Exception
  34. {
  35. };
  36. //=============================================================================
  37. //
  38. // RepCollectionItem
  39. //
  40. // This structure is used to associate a key to the stored pointer when
  41. // we have a single item or an array of items. The AvlTree has it's own
  42. // object to do this task so we do not need it for that.
  43. //=============================================================================
  44. struct RepCollectionItem
  45. {
  46. public:
  47. DWORD_PTR poKey; //Offset within MMF of key. We own this key value.
  48. DWORD_PTR poItem; //Offset within MMF of item. We do not own the object this points to!
  49. };
  50. struct RepCollection
  51. {
  52. private:
  53. enum { none, single_item, array, tree} m_repType;
  54. enum { MAX_ARRAY_SIZE = 10 };
  55. DWORD m_dwSize;
  56. union
  57. {
  58. DWORD_PTR m_poSingleItem;
  59. CDbArray *m_poDbArray;
  60. CDbAvlTree *m_poDbAvlTree;
  61. };
  62. };
  63. //Repository of pointers stored in reference tables.
  64. //If the list is one item it is a direct pointer, if a small number of items
  65. //(say 10) it is a CDbArray, otherwise we use a CDbAvlTree.
  66. struct PtrCollection
  67. {
  68. enum { none, single_item, array, tree} m_repType;
  69. enum { MAX_ARRAY_SIZE = 10 };
  70. DWORD m_dwSize;
  71. union
  72. {
  73. DWORD_PTR m_poPtr;
  74. CDbArray *m_poDbArray;
  75. CDbAvlTree *m_poDbAvlTree;
  76. };
  77. };
  78. struct NSREP
  79. {
  80. enum { flag_normal = 0x1, flag_hidden = 0x2, flag_temp = 0x4,
  81. flag_system = 0x8
  82. };
  83. // Data members.
  84. // =============
  85. RepCollection *m_poNamespaces; // Child namespaces, based ptr
  86. LPWSTR m_poName; // Namespace name, based ptr
  87. INSTDEF *m_poObjectDef; // 'Real' object definition, based ptr
  88. DWORD m_dwFlags; // Hidden, normal, temp, system, etc.
  89. CDbAvlTree *m_poClassTree; // Class tree by Name, CLASSDEF structs, based tr
  90. NSREP *m_poParentNs; // Owning namespace, based ptr
  91. DWORD_PTR m_poSecurity;
  92. };
  93. /////////////////////////////////////////////////////////////////////////////
  94. struct INSTDEF
  95. {
  96. enum
  97. {
  98. genus_class = WBEM_GENUS_CLASS, //defined in IDL, 1
  99. genus_instance = WBEM_GENUS_INSTANCE, //defined in IDL, 2
  100. compressed = 0x100
  101. };
  102. NSREP *m_poOwningNs; // back ptr for debugging, based ptr
  103. CLASSDEF *m_poOwningClass; // back ptr for debugging, based ptr
  104. DWORD m_dwFlags; // Genus, etc.
  105. LPVOID m_poObjectStream; // Ptr to object stream, based ptr
  106. PtrCollection *m_poRefTable; // List of references to this object
  107. };
  108. /////////////////////////////////////////////////////////////////////////////
  109. #define MAX_SECONDARY_INDICES 4
  110. struct SINDEXTABLE
  111. {
  112. DWORD m_aPropTypes[MAX_SECONDARY_INDICES]; // VT_ type of the property.
  113. LPWSTR m_aPropertyNames[MAX_SECONDARY_INDICES]; // NULL entries indicate nothing
  114. CDbAvlTree *m_apoLookupTrees[MAX_SECONDARY_INDICES]; // Parallel to above names
  115. };
  116. /////////////////////////////////////////////////////////////////////////////
  117. struct CLASSDEF
  118. {
  119. enum { keyed = 0x1,
  120. unkeyed = 0x2,
  121. indexed = 0x4,
  122. abstract = 0x08,
  123. borrowed_index = 0x10,
  124. dynamic = 0x20,
  125. // has_refs = 0x40,
  126. singleton = 0x80,
  127. compressed = 0x100,
  128. has_class_refs = 0x200
  129. };
  130. // Data members.
  131. // =============
  132. NSREP *m_poOwningNs; // Back reference to owning namespace, based ptr
  133. INSTDEF *m_poClassDef; // Local definition mixed with instances, based ptr
  134. CLASSDEF *m_poSuperclass; // Immediate parent class, based ptr
  135. DWORD m_dwFlags; // Various combinations of the above enum flags
  136. CDbAvlTree *m_poKeyTree; // Instances by key, based ptr
  137. PtrCollection*m_poSubclasses; // Child classes, based ptr
  138. SINDEXTABLE *m_poSecondaryIx; // Based ptr to secondary indices
  139. PtrCollection*m_poInboundRefClasses; // Classes which may have dyn instances which reference
  140. // objects of this class
  141. };
  142. /////////////////////////////////////////////////////////////////////////////
  143. struct DANGREF : public RepCollection
  144. {
  145. };
  146. struct DANGREFCLASS : public RepCollection
  147. {};
  148. struct DANGREFKEY : public RepCollection
  149. {};
  150. /////////////////////////////////////////////////////////////////////////////
  151. struct DANGLREFSCHEMA : public RepCollection
  152. {};
  153. struct DANGREFSCHEMA : public RepCollection
  154. {};
  155. struct DANGREFSCHEMACLASS : public RepCollection
  156. {
  157. };
  158. /////////////////////////////////////////////////////////////////////////////
  159. #define DB_ROOT_CLEAN 0x0
  160. #define DB_ROOT_INUSE 0x1
  161. struct DBROOT
  162. {
  163. public:
  164. time_t m_tCreate;
  165. time_t m_tUpdate;
  166. DWORD m_dwFlags; // in-use, stable, etc.
  167. NSREP *m_poRootNs; // ROOT namespace
  168. DANGREF *m_poDanglingRefTbl; // Dangling reference table
  169. DANGREFSCHEMA *m_poSchemaDanglingRefTbl;// Same as above but for schema-based fixups
  170. };
  171. #endif