Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:17

0001 // Copyright (c) 1998-1999 Matra Datavision
0002 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _Storage_BucketOfPersistent_HeaderFile
0016 #define _Storage_BucketOfPersistent_HeaderFile
0017 
0018 #include <Standard_Integer.hxx>
0019 #include <Standard_Persistent.hxx>
0020 
0021 class Storage_Schema;
0022 class Storage_BucketOfPersistent;
0023 class Storage_BucketIterator;
0024 
0025 class Storage_Bucket {
0026   friend class Storage_BucketIterator;
0027   friend class Storage_Schema;
0028   friend class Storage_BucketOfPersistent;
0029 
0030   Standard_Persistent** mySpace;
0031   Standard_Integer mySpaceSize;
0032   Standard_Integer myCurrentSpace;
0033 
0034 
0035   void Append(Standard_Persistent *);
0036  
0037   Standard_Persistent* Value(const Standard_Integer theIndex) const;
0038 
0039 public:
0040   Storage_Bucket() : mySpace(0L), mySpaceSize(200000), myCurrentSpace(-1)
0041     {
0042       mySpace = (Standard_Persistent**)Standard::Allocate(sizeof(Standard_Persistent*) * mySpaceSize);
0043     }
0044 
0045   Storage_Bucket(const Standard_Integer theSpaceSize) :  mySpace(0L), mySpaceSize(theSpaceSize), myCurrentSpace(-1)
0046     {
0047       mySpace = (Standard_Persistent**)Standard::Allocate(sizeof(Standard_Persistent*) * mySpaceSize);
0048     }
0049 
0050   void Clear();
0051 
0052   ~Storage_Bucket();
0053 };
0054 
0055 
0056 class Storage_BucketOfPersistent {
0057   friend class Storage_BucketIterator;
0058   Storage_Bucket** myBuckets;
0059   Standard_Integer myNumberOfBucket;
0060   Standard_Integer myNumberOfBucketAllocated;
0061   Storage_Bucket*  myCurrentBucket;
0062   Standard_Integer myCurrentBucketNumber;
0063   Standard_Integer myLength;
0064   Standard_Integer myBucketSize;
0065   
0066 public:
0067   Storage_BucketOfPersistent(const Standard_Integer theBucketSize = 300000, const Standard_Integer theBucketNumber = 100);
0068   
0069   Standard_Integer Length() const
0070     {
0071       return myLength;
0072     }
0073 
0074   void Append(const Handle(Standard_Persistent)& sp);
0075   
0076   Standard_Persistent* Value(const Standard_Integer theIndex);
0077 
0078   void Clear();
0079 
0080   ~Storage_BucketOfPersistent() ;
0081 
0082 };
0083 
0084 class Storage_BucketIterator {
0085   Storage_BucketOfPersistent *myBucket;
0086   Storage_Bucket             *myCurrentBucket;
0087   Standard_Integer            myCurrentBucketIndex;
0088   Standard_Integer            myCurrentIndex;
0089   Standard_Integer            myBucketNumber;
0090   Standard_Boolean            myMoreObject;
0091 
0092 public:
0093   Storage_BucketIterator(Storage_BucketOfPersistent*);
0094   void Init(Storage_BucketOfPersistent*);
0095   void Reset();
0096 
0097   Standard_Persistent* Value() const
0098     {
0099       if (myCurrentBucket) {
0100     return myCurrentBucket->mySpace[myCurrentIndex];
0101       }
0102       else return 0L;
0103     }
0104 
0105   Standard_Boolean More() const
0106     {
0107       return myMoreObject;
0108     }
0109 
0110   void Next();
0111 };
0112 
0113 #endif