Back to home page

EIC code displayed by LXR

 
 

    


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 // Created on: 2001-06-26
0002 // Created by: Alexander GRIGORIEV
0003 // Copyright (c) 2001-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
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 // Define handle class for LDOM_MemManager
0027 DEFINE_STANDARD_HANDLE (LDOM_MemManager, Standard_Transient)
0028 
0029 //  Class LDOM_MemManager (underlying structure of LDOM_Document)
0030 //
0031 
0032 class LDOM_MemManager : public Standard_Transient
0033 {
0034  public:
0035   // ---------- PUBLIC METHODS ----------
0036 
0037   Standard_EXPORT LDOM_MemManager       (const Standard_Integer aBlockSize);
0038   // Constructor
0039 
0040   Standard_EXPORT ~LDOM_MemManager      ();
0041   // Destructor
0042 
0043   Standard_EXPORT void * Allocate       (const Standard_Integer aSize);
0044   // General Memory allocator
0045 
0046   const char *           HashedAllocate (const char             * aString,
0047                                          const Standard_Integer theLen,
0048                                          Standard_Integer&      theHash);
0049   // Memory allocation with access via hash table. No new allocation
0050   // if already present 
0051 
0052   void                   HashedAllocate (const char             * aString,
0053                                          const Standard_Integer theLen,
0054                                          LDOMBasicString&      theResult);
0055   // Memory allocation with access via hash table. No new allocation
0056   // if already present 
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 //  LDOM_Document           Doc           () const
0067 //                                { return LDOM_Document (* this); }
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   // ---- CLASS MemBlock ----
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   // ---- CLASS HashTable ----
0096   class HashTable {
0097     friend class LDOM_MemManager;
0098     HashTable                   (/* const Standard_Integer theMask, */
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   // ---- PROHIBITED (PRIVATE) METHODS ----
0114   LDOM_MemManager (const LDOM_MemManager& theOther);
0115   // Copy constructor
0116 
0117   LDOM_MemManager& operator = (const LDOM_MemManager& theOther);
0118   // Assignment
0119 
0120   // ---------- PRIVATE FIELDS ----------
0121 
0122   const LDOM_BasicElement * myRootElement;
0123   MemBlock              * myFirstBlock;
0124   MemBlock              * myFirstWithoutRoom;
0125   Standard_Integer      myBlockSize;
0126   HashTable             * myHashTable;
0127 
0128  public:
0129   // CASCADE RTTI
0130   DEFINE_STANDARD_RTTIEXT(LDOM_MemManager,Standard_Transient)
0131 };
0132 
0133 
0134 #endif