Warning, file /include/opencascade/LDOM_MemManager.hxx was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef LDOM_MemManager_HeaderFile
0017 #define LDOM_MemManager_HeaderFile
0018
0019 #include <Standard_Transient.hxx>
0020 #include <Standard_Type.hxx>
0021
0022 class LDOM_BasicElement;
0023 class LDOM_MemManager;
0024 class LDOMBasicString;
0025
0026
0027 DEFINE_STANDARD_HANDLE (LDOM_MemManager, Standard_Transient)
0028
0029
0030
0031
0032 class LDOM_MemManager : public Standard_Transient
0033 {
0034 public:
0035
0036
0037 Standard_EXPORT LDOM_MemManager (const Standard_Integer aBlockSize);
0038
0039
0040 Standard_EXPORT ~LDOM_MemManager ();
0041
0042
0043 Standard_EXPORT void * Allocate (const Standard_Integer aSize);
0044
0045
0046 const char * HashedAllocate (const char * aString,
0047 const Standard_Integer theLen,
0048 Standard_Integer& theHash);
0049
0050
0051
0052 void HashedAllocate (const char * aString,
0053 const Standard_Integer theLen,
0054 LDOMBasicString& theResult);
0055
0056
0057
0058 static Standard_Integer Hash (const char * theString,
0059 const Standard_Integer theLen)
0060 { return HashTable::Hash (theString, theLen); }
0061
0062 static Standard_Boolean CompareStrings(const char * theString,
0063 const Standard_Integer theHashValue,
0064 const char * theHashedStr);
0065
0066
0067
0068
0069 const LDOM_MemManager& Self () const
0070 { return * this; }
0071
0072 const LDOM_BasicElement * RootElement () const
0073 { return myRootElement; }
0074
0075 private:
0076 friend class LDOM_Document;
0077 friend class LDOMParser;
0078
0079
0080 class MemBlock {
0081 friend class LDOM_MemManager;
0082 inline MemBlock (const Standard_Integer aSize, MemBlock * aFirst);
0083 inline void * Allocate (const Standard_Integer aSize);
0084 void * AllocateAndCheck (const Standard_Integer aSize, const MemBlock *&);
0085 ~MemBlock ();
0086 MemBlock * Next () { return myNext; }
0087
0088 Standard_Integer mySize;
0089 Standard_Integer * myBlock;
0090 Standard_Integer * myEndBlock;
0091 Standard_Integer * myFreeSpace;
0092 MemBlock * myNext;
0093 };
0094
0095
0096 class HashTable {
0097 friend class LDOM_MemManager;
0098 HashTable (
0099 LDOM_MemManager& theMemManager);
0100 const char * AddString (const char * theString,
0101 const Standard_Integer theLen,
0102 Standard_Integer& theHashIndex);
0103 static Standard_Integer Hash(const char * theString,
0104 const Standard_Integer theLen);
0105 struct TableItem {
0106 char * str;
0107 struct TableItem * next;
0108 } * myTable;
0109 LDOM_MemManager& myManager;
0110 void operator= (const HashTable&);
0111 };
0112
0113
0114 LDOM_MemManager (const LDOM_MemManager& theOther);
0115
0116
0117 LDOM_MemManager& operator = (const LDOM_MemManager& theOther);
0118
0119
0120
0121
0122 const LDOM_BasicElement * myRootElement;
0123 MemBlock * myFirstBlock;
0124 MemBlock * myFirstWithoutRoom;
0125 Standard_Integer myBlockSize;
0126 HashTable * myHashTable;
0127
0128 public:
0129
0130 DEFINE_STANDARD_RTTIEXT(LDOM_MemManager,Standard_Transient)
0131 };
0132
0133
0134 #endif