Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:19:34

0001 // Copyright (c) 2026 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _BRepGraph_CacheIterator_HeaderFile
0015 #define _BRepGraph_CacheIterator_HeaderFile
0016 
0017 #include <BRepGraph_CacheRegistry.hxx>
0018 #include <NCollection_ForwardRange.hxx>
0019 
0020 //! @brief Iterator over registered cache families in a BRepGraph_CacheRegistry.
0021 //!
0022 //! Supports OCCT More()/Next()/Value() pattern and STL range-for via begin()/end().
0023 class BRepGraph_CacheIterator
0024 {
0025 public:
0026   //! Construct an iterator over all cache families in the registry.
0027   explicit BRepGraph_CacheIterator(const BRepGraph_CacheRegistry& theRegistry)
0028       : myRegistry(&theRegistry),
0029         myCount(theRegistry.NbCaches())
0030   {
0031   }
0032 
0033   //! True if the iterator has a current element.
0034   [[nodiscard]] bool More() const { return myCurrent < myCount; }
0035 
0036   //! Advance to the next cache family.
0037   void Next() { ++myCurrent; }
0038 
0039   //! Return the current cache family descriptor.
0040   [[nodiscard]] occ::handle<BRepGraph_Cache> Value() const { return myRegistry->Cache(myCurrent); }
0041 
0042   //! Return the current slot index in the registry.
0043   [[nodiscard]] uint32_t Slot() const { return myCurrent; }
0044 
0045   //! Number of cache families in the registry.
0046   [[nodiscard]] uint32_t NbCaches() const { return myRegistry->NbCaches(); }
0047 
0048   //! STL range-for support.
0049   NCollection_ForwardRangeIterator<BRepGraph_CacheIterator> begin()
0050   {
0051     return NCollection_ForwardRangeIterator<BRepGraph_CacheIterator>(this);
0052   }
0053 
0054   //! Sentinel marking end of iteration.
0055   NCollection_ForwardRangeSentinel end() const { return NCollection_ForwardRangeSentinel{}; }
0056 
0057 private:
0058   const BRepGraph_CacheRegistry* myRegistry;
0059   uint32_t                       myCount;
0060   uint32_t                       myCurrent = 0;
0061 };
0062 
0063 #endif // _BRepGraph_CacheIterator_HeaderFile