Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Data Structures | Public Member Functions | Static Public Attributes
BRepGraph_TransientCache Class Reference

Centralized transient cache for algorithm-computed per-node values. More...

#include <BRepGraph_TransientCache.hxx>

Data Structures

struct  CacheSlot
 Per-slot storage: cached value handle + SubtreeGen stamp. More...
 

Public Member Functions

void Set (const BRepGraph_NodeId theNode, const occ::handle< BRepGraph_CacheKind > &theKind, const occ::handle< BRepGraph_CacheValue > &theValue, const uint32_t theCurrentSubtreeGen)
 Store a cached value for a node and cache kind.
 
void Set (const BRepGraph_NodeId theNode, const int theKindSlot, const occ::handle< BRepGraph_CacheValue > &theValue, const uint32_t theCurrentSubtreeGen)
 Store a cached value using a pre-resolved kind slot index. Bypasses BRepGraph_CacheKindRegistry lookup - use in hot parallel paths.
 
occ::handle< BRepGraph_CacheValueGet (const BRepGraph_NodeId theNode, const occ::handle< BRepGraph_CacheKind > &theKind, const uint32_t theCurrentSubtreeGen) const
 Retrieve a cached value for a node and cache kind.
 
occ::handle< BRepGraph_CacheValueGet (const BRepGraph_NodeId theNode, const int theKindSlot, const uint32_t theCurrentSubtreeGen) const
 Retrieve a cached value using a pre-resolved kind slot index. Bypasses BRepGraph_CacheKindRegistry lookup - use in hot parallel paths.
 
bool Remove (const BRepGraph_NodeId theNode, const occ::handle< BRepGraph_CacheKind > &theKind)
 Remove a cached value for a node and cache kind.
 
bool Remove (const BRepGraph_NodeId theNode, const int theKindSlot)
 Remove a cached value using a pre-resolved cache-kind slot.
 
int CollectCacheKindSlots (const BRepGraph_NodeId theNode, const uint32_t theCurrentSubtreeGen, int theSlots[]) const
 Collect fresh cache-kind slot indices for a node (zero heap allocation). Used internally by CacheView::CacheKindIterator.
 
void Reserve (const int theKindCount, const int theCounts[THE_KIND_COUNT])
 Pre-allocate storage for lock-free parallel access.
 
bool IsReserved () const noexcept
 True if Reserve() has been called and storage is pre-allocated.
 
void Clear () noexcept
 Clear all cached data. Called on BRepGraph_Builder::Add() and Compact().
 
 BRepGraph_TransientCache (BRepGraph_TransientCache &&theOther) noexcept
 Move constructor: transfers data, creates fresh mutex.
 
BRepGraph_TransientCacheoperator= (BRepGraph_TransientCache &&theOther) noexcept
 Move assignment: transfers data, mutex stays local.
 
 BRepGraph_TransientCache ()=default
 
 BRepGraph_TransientCache (const BRepGraph_TransientCache &)=delete
 
BRepGraph_TransientCacheoperator= (const BRepGraph_TransientCache &)=delete
 

Static Public Attributes

static constexpr int THE_KIND_COUNT = BRepGraph_NodeId::THE_KIND_COUNT
 Number of Kind enum slots to cover (0..11, with gap at 9).
 
static constexpr int THE_DEFAULT_RESERVED_KIND_COUNT = 16
 Default number of cache-kind slots reserved after BRepGraph_Builder::Add().
 

Detailed Description

Centralized transient cache for algorithm-computed per-node values.

Stores short-lived cached data (BndBox, UVBounds, etc.) in dense per-cache-kind vectors indexed by entity index. O(1) access by direct indexing - no hashing.

SubtreeGen-based freshness

Each stored slot records SubtreeGen at write time. On read, if stored SubtreeGen differs from entity's current SubtreeGen the cached value is considered stale - the caller decides how to handle it.

Lifecycle

NOT a Layer. Cleared on BRepGraph_Builder::Add() and Compact(). No OnNodeRemoved handling - stale data is auto-detected by SubtreeGen mismatch.

Thread safety

After Reserve(), Get() and Set() for in-range indices bypass the mutex entirely - safe because parallel algorithms access different entity slots. Out-of-range access (entities added after construction) falls back to mutex.

Constructor & Destructor Documentation

◆ BRepGraph_TransientCache() [1/3]

BRepGraph_TransientCache::BRepGraph_TransientCache ( BRepGraph_TransientCache && theOther)
inlinenoexcept

Move constructor: transfers data, creates fresh mutex.

◆ BRepGraph_TransientCache() [2/3]

BRepGraph_TransientCache::BRepGraph_TransientCache ( )
default

◆ BRepGraph_TransientCache() [3/3]

BRepGraph_TransientCache::BRepGraph_TransientCache ( const BRepGraph_TransientCache & )
delete

Member Function Documentation

◆ Clear()

void BRepGraph_TransientCache::Clear ( )
noexcept

Clear all cached data. Called on BRepGraph_Builder::Add() and Compact().

◆ CollectCacheKindSlots()

int BRepGraph_TransientCache::CollectCacheKindSlots ( const BRepGraph_NodeId theNode,
const uint32_t theCurrentSubtreeGen,
int theSlots[] ) const

Collect fresh cache-kind slot indices for a node (zero heap allocation). Used internally by CacheView::CacheKindIterator.

Parameters
[in]theNodenode to query
[in]theCurrentSubtreeGenfreshness stamp to match
[out]theSlotsoutput array (caller-allocated, must hold THE_DEFAULT_RESERVED_KIND_COUNT)
Returns
number of populated slots written to theSlots

◆ Get() [1/2]

occ::handle< BRepGraph_CacheValue > BRepGraph_TransientCache::Get ( const BRepGraph_NodeId theNode,
const int theKindSlot,
const uint32_t theCurrentSubtreeGen ) const

Retrieve a cached value using a pre-resolved kind slot index. Bypasses BRepGraph_CacheKindRegistry lookup - use in hot parallel paths.

Parameters
[in]theKindSlotslot from BRepGraph_CacheKindRegistry::Register()

◆ Get() [2/2]

occ::handle< BRepGraph_CacheValue > BRepGraph_TransientCache::Get ( const BRepGraph_NodeId theNode,
const occ::handle< BRepGraph_CacheKind > & theKind,
const uint32_t theCurrentSubtreeGen ) const

Retrieve a cached value for a node and cache kind.

Precondition
Reserve() must have been called for lock-free parallel access on in-range entity indices; out-of-range access falls back to mutex.

◆ IsReserved()

bool BRepGraph_TransientCache::IsReserved ( ) const
inlinenoexcept

True if Reserve() has been called and storage is pre-allocated.

◆ operator=() [1/2]

BRepGraph_TransientCache & BRepGraph_TransientCache::operator= ( BRepGraph_TransientCache && theOther)
inlinenoexcept

Move assignment: transfers data, mutex stays local.

◆ operator=() [2/2]

BRepGraph_TransientCache & BRepGraph_TransientCache::operator= ( const BRepGraph_TransientCache & )
delete

◆ Remove() [1/2]

bool BRepGraph_TransientCache::Remove ( const BRepGraph_NodeId theNode,
const int theKindSlot )

Remove a cached value using a pre-resolved cache-kind slot.

◆ Remove() [2/2]

bool BRepGraph_TransientCache::Remove ( const BRepGraph_NodeId theNode,
const occ::handle< BRepGraph_CacheKind > & theKind )

Remove a cached value for a node and cache kind.

◆ Reserve()

void BRepGraph_TransientCache::Reserve ( const int theKindCount,
const int theCounts[THE_KIND_COUNT] )

Pre-allocate storage for lock-free parallel access.

◆ Set() [1/2]

void BRepGraph_TransientCache::Set ( const BRepGraph_NodeId theNode,
const int theKindSlot,
const occ::handle< BRepGraph_CacheValue > & theValue,
const uint32_t theCurrentSubtreeGen )

Store a cached value using a pre-resolved kind slot index. Bypasses BRepGraph_CacheKindRegistry lookup - use in hot parallel paths.

Parameters
[in]theKindSlotslot from BRepGraph_CacheKindRegistry::Register()

◆ Set() [2/2]

void BRepGraph_TransientCache::Set ( const BRepGraph_NodeId theNode,
const occ::handle< BRepGraph_CacheKind > & theKind,
const occ::handle< BRepGraph_CacheValue > & theValue,
const uint32_t theCurrentSubtreeGen )

Store a cached value for a node and cache kind.

Precondition
Reserve() must have been called for lock-free parallel access on in-range entity indices; out-of-range access falls back to mutex.

Field Documentation

◆ THE_DEFAULT_RESERVED_KIND_COUNT

constexpr int BRepGraph_TransientCache::THE_DEFAULT_RESERVED_KIND_COUNT = 16
staticconstexpr

Default number of cache-kind slots reserved after BRepGraph_Builder::Add().

◆ THE_KIND_COUNT

constexpr int BRepGraph_TransientCache::THE_KIND_COUNT = BRepGraph_NodeId::THE_KIND_COUNT
staticconstexpr

Number of Kind enum slots to cover (0..11, with gap at 9).


The documentation for this class was generated from the following file: