1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef _Storage_BucketOfPersistent_HeaderFile
16 #define _Storage_BucketOfPersistent_HeaderFile
18 #include <Standard_Integer.hxx>
19 #include <Standard_Persistent.hxx>
22 class Storage_BucketOfPersistent;
23 class Storage_BucketIterator;
25 class Storage_Bucket {
26 friend class Storage_BucketIterator;
27 friend class Storage_Schema;
28 friend class Storage_BucketOfPersistent;
30 Standard_Persistent** mySpace;
31 Standard_Integer mySpaceSize;
32 Standard_Integer myCurrentSpace;
35 void Append(Standard_Persistent *);
37 Standard_Persistent* Value(const Standard_Integer theIndex) const;
40 Storage_Bucket() : mySpace(0L), mySpaceSize(200000), myCurrentSpace(-1)
42 mySpace = (Standard_Persistent**)Standard::Allocate(sizeof(Standard_Persistent*) * mySpaceSize);
45 Storage_Bucket(const Standard_Integer theSpaceSize) : mySpace(0L), mySpaceSize(theSpaceSize), myCurrentSpace(-1)
47 mySpace = (Standard_Persistent**)Standard::Allocate(sizeof(Standard_Persistent*) * mySpaceSize);
56 class Storage_BucketOfPersistent {
57 friend class Storage_BucketIterator;
58 Storage_Bucket** myBuckets;
59 Standard_Integer myNumberOfBucket;
60 Standard_Integer myNumberOfBucketAllocated;
61 Storage_Bucket* myCurrentBucket;
62 Standard_Integer myCurrentBucketNumber;
63 Standard_Integer myLength;
64 Standard_Integer myBucketSize;
67 Storage_BucketOfPersistent(const Standard_Integer theBucketSize = 300000, const Standard_Integer theBucketNumber = 100);
69 Standard_Integer Length() const
74 void Append(const Handle(Standard_Persistent)& sp);
76 Standard_Persistent* Value(const Standard_Integer theIndex);
80 ~Storage_BucketOfPersistent() ;
84 class Storage_BucketIterator {
85 Storage_BucketOfPersistent *myBucket;
86 Storage_Bucket *myCurrentBucket;
87 Standard_Integer myCurrentBucketIndex;
88 Standard_Integer myCurrentIndex;
89 Standard_Integer myBucketNumber;
90 Standard_Boolean myMoreObject;
93 Storage_BucketIterator(Storage_BucketOfPersistent*);
94 void Init(Storage_BucketOfPersistent*);
97 Standard_Persistent* Value() const
99 if (myCurrentBucket) {
100 return myCurrentBucket->mySpace[myCurrentIndex];
105 Standard_Boolean More() const