Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-15 09:17:21

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 {
0027   friend class Storage_BucketIterator;
0028   friend class Storage_Schema;
0029   friend class Storage_BucketOfPersistent;
0030 
0031   Standard_Persistent** mySpace;
0032   int                   mySpaceSize;
0033   int                   myCurrentSpace;
0034 
0035   void Append(Standard_Persistent*);
0036 
0037   Standard_Persistent* Value(const int theIndex) const;
0038 
0039 public:
0040   Storage_Bucket()
0041       : mySpace(nullptr),
0042         mySpaceSize(200000),
0043         myCurrentSpace(-1)
0044   {
0045     mySpace = (Standard_Persistent**)Standard::Allocate(sizeof(Standard_Persistent*) * mySpaceSize);
0046   }
0047 
0048   Storage_Bucket(const int theSpaceSize)
0049       : mySpace(nullptr),
0050         mySpaceSize(theSpaceSize),
0051         myCurrentSpace(-1)
0052   {
0053     mySpace = (Standard_Persistent**)Standard::Allocate(sizeof(Standard_Persistent*) * mySpaceSize);
0054   }
0055 
0056   void Clear();
0057 
0058   ~Storage_Bucket();
0059 };
0060 
0061 class Storage_BucketOfPersistent
0062 {
0063   friend class Storage_BucketIterator;
0064   Storage_Bucket** myBuckets;
0065   int              myNumberOfBucket;
0066   int              myNumberOfBucketAllocated;
0067   Storage_Bucket*  myCurrentBucket;
0068   int              myCurrentBucketNumber;
0069   int              myLength;
0070   int              myBucketSize;
0071 
0072 public:
0073   Storage_BucketOfPersistent(const int theBucketSize = 300000, const int theBucketNumber = 100);
0074 
0075   int Length() const { return myLength; }
0076 
0077   void Append(const occ::handle<Standard_Persistent>& sp);
0078 
0079   Standard_Persistent* Value(const int theIndex);
0080 
0081   void Clear();
0082 
0083   ~Storage_BucketOfPersistent();
0084 };
0085 
0086 class Storage_BucketIterator
0087 {
0088   Storage_BucketOfPersistent* myBucket;
0089   Storage_Bucket*             myCurrentBucket;
0090   int                         myCurrentBucketIndex;
0091   int                         myCurrentIndex;
0092   int                         myBucketNumber;
0093   bool                        myMoreObject;
0094 
0095 public:
0096   Storage_BucketIterator(Storage_BucketOfPersistent*);
0097   void Init(Storage_BucketOfPersistent*);
0098   void Reset();
0099 
0100   Standard_Persistent* Value() const
0101   {
0102     if (myCurrentBucket)
0103     {
0104       return myCurrentBucket->mySpace[myCurrentIndex];
0105     }
0106     else
0107       return nullptr;
0108   }
0109 
0110   bool More() const { return myMoreObject; }
0111 
0112   void Next();
0113 };
0114 
0115 #endif