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.

149 lines
4.1 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1997
  6. //
  7. // File: model.h
  8. //
  9. //--------------------------------------------------------------------------
  10. //
  11. // MODEL.H
  12. //
  13. #ifndef _MODEL_H_
  14. #define _MODEL_H_
  15. #include "gelem.h" // Graph object classes
  16. #include "glnkenum.h"
  17. #include "symtmbn.h" // Symbol table and string declarations
  18. #include "gelmwalk.h" // Graph search algorithms
  19. #include "gmprop.h"
  20. class MODEL
  21. {
  22. public:
  23. // Nested iterator class based on symbol table iteration.
  24. class ITER
  25. {
  26. public:
  27. ITER ( MODEL& model, GOBJMBN::EBNOBJ eType );
  28. ITER ( MODEL& model );
  29. void CreateNodeIterator();
  30. bool operator++ (int i)
  31. { return BNext() ; }
  32. bool operator++ ()
  33. { return BNext() ; }
  34. GOBJMBN * operator -> ()
  35. { return _pCurrent; }
  36. GOBJMBN * operator * ()
  37. { return _pCurrent; }
  38. ZSREF ZsrCurrent ()
  39. { return _zsrCurrent; }
  40. void Reset ();
  41. protected:
  42. MPSYMTBL::iterator _itsym;
  43. GOBJMBN::EBNOBJ _eType;
  44. GOBJMBN* _pCurrent;
  45. ZSREF _zsrCurrent;
  46. protected:
  47. bool BNext();
  48. MODEL& _model;
  49. };
  50. public:
  51. MODEL ();
  52. virtual ~ MODEL ();
  53. GRPH * Pgraph () const
  54. { return _pgrph; }
  55. GRPH & Grph () const
  56. {
  57. assert( _pgrph );
  58. return *_pgrph;
  59. }
  60. // Object addition and deletion functions
  61. // Add and delete generic unnamed elements
  62. virtual void AddElem ( GELEMLNK * pgelm );
  63. virtual void DeleteElem ( GELEMLNK * pgelem );
  64. // Add and delete named elements
  65. // Test the name for duplicate; add if not, else return false
  66. virtual bool BAddElem ( SZC szcName, GOBJMBN * pgobj );
  67. // Add a named object to the graph and symbol table
  68. virtual void AddElem ( SZC szcName, GOBJMBN * pgobj );
  69. // Delete objects and edges
  70. virtual void DeleteElem ( GOBJMBN * pgobj );
  71. // Enumerator for contents of the graph (GRPH);
  72. // enumeration omits the GRPH object itself
  73. class MODELENUM : public GLNKENUM<GELEMLNK,true>
  74. {
  75. public:
  76. MODELENUM ( const MODEL & model )
  77. : GLNKENUM<GELEMLNK,true>( model.Grph() )
  78. {}
  79. };
  80. // Accessors to format/versioning info
  81. REAL & RVersion () { return _rVersion ; }
  82. ZSTR & ZsFormat () { return _zsFormat; }
  83. ZSTR & ZsCreator () { return _zsCreator; }
  84. ZSTR & ZsNetworkID () { return _zsNetworkID; }
  85. // Accessor for symbol table
  86. MPSYMTBL & Mpsymtbl () { return _mpsymtbl; }
  87. const MPSYMTBL & Mpsymtbl () const
  88. { return _mpsymtbl; }
  89. GOBJMBN * PgobjFind ( SZC szcName );
  90. // Accessor for list of network-level properties
  91. LTBNPROP & LtProp () { return _ltProp; }
  92. // Accessors for the array of flag bits
  93. bool BFlag ( IBFLAG ibf ) const
  94. { return _vFlags.BFlag( ibf ); }
  95. bool BSetBFlag ( IBFLAG ibf, bool bValue = true )
  96. { return _vFlags.BSetBFlag( ibf, bValue ); }
  97. // Name validation and parsing functions
  98. // Return a character which is illegal in a DSC-file-based name;
  99. // used for building up "hidden" but otherwise descriptive names
  100. static char ChInternal () { return '$'; }
  101. // Return true if the character is legal in a name
  102. enum ECHNAME { ECHNM_First, ECHNM_Middle, ECHNM_Last };
  103. static bool BChLegal ( char ch, ECHNAME echnm, bool bInternal = false );
  104. // Return true if the name is legal
  105. static bool BSzLegal ( SZC szcName, bool bInternal = false );
  106. // Return a displayable string associated with an error code; NULL if not found
  107. static SZC SzcFromEc ( ECGM ec );
  108. protected:
  109. GRPH * _pgrph; // The graph
  110. // Format and versioning info
  111. REAL _rVersion; // Version/revision value
  112. ZSTR _zsFormat; // Format type string
  113. ZSTR _zsCreator; // Creator name
  114. ZSTR _zsNetworkID; // Network identification string
  115. MPSYMTBL _mpsymtbl; // The symbol table
  116. LTBNPROP _ltProp; // The list of user-definable properties
  117. VFLAGS _vFlags; // Bit vector of flags
  118. protected:
  119. // Set or reset the graph object
  120. virtual void SetPgraph ( GRPH * pgrph );
  121. // Protected clone-this-from-other operation
  122. virtual void Clone ( MODEL & model );
  123. };
  124. #endif