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

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

#include <BRepGraph_RefTransientCache.hxx>

Data Structures

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

Public Member Functions

void Set (const BRepGraph_RefId theRef, const occ::handle< BRepGraph_CacheKind > &theKind, const occ::handle< BRepGraph_CacheValue > &theValue, const uint32_t theCurrentOwnGen)
 Store a cached value for a reference and cache kind.
 
void Set (const BRepGraph_RefId theRef, const int theKindSlot, const occ::handle< BRepGraph_CacheValue > &theValue, const uint32_t theCurrentOwnGen)
 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_RefId theRef, const occ::handle< BRepGraph_CacheKind > &theKind, const uint32_t theCurrentOwnGen) const
 Retrieve a cached value for a reference and cache kind. Returns null handle if no value is stored or if OwnGen has changed.
 
occ::handle< BRepGraph_CacheValueGet (const BRepGraph_RefId theRef, const int theKindSlot, const uint32_t theCurrentOwnGen) const
 Retrieve a cached value using a pre-resolved kind slot index.
 
bool Remove (const BRepGraph_RefId theRef, const occ::handle< BRepGraph_CacheKind > &theKind)
 Remove a cached value for a reference and cache kind.
 
bool Remove (const BRepGraph_RefId theRef, const int theKindSlot)
 Remove a cached value using a pre-resolved cache-kind slot.
 
int CollectCacheKindSlots (const BRepGraph_RefId theRef, const uint32_t theCurrentOwnGen, int theSlots[]) const
 Collect fresh cache-kind slot indices for a reference (zero heap allocation). Used internally by CacheView::CacheKindIterator.
 
void Reserve (const int theKindCount, const int theCounts[THE_REF_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_RefTransientCache (BRepGraph_RefTransientCache &&theOther) noexcept
 Move constructor: transfers data, creates fresh mutex.
 
BRepGraph_RefTransientCacheoperator= (BRepGraph_RefTransientCache &&theOther) noexcept
 Move assignment: transfers data, mutex stays local.
 
 BRepGraph_RefTransientCache ()=default
 
 BRepGraph_RefTransientCache (const BRepGraph_RefTransientCache &)=delete
 
BRepGraph_RefTransientCacheoperator= (const BRepGraph_RefTransientCache &)=delete
 

Static Public Attributes

static constexpr int THE_REF_KIND_COUNT = 8
 Number of BRepGraph_RefId::Kind enum values (Shell..Occurrence = 0..7).
 
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-reference values.

Symmetric counterpart of BRepGraph_TransientCache, keyed by BRepGraph_RefId instead of BRepGraph_NodeId. Freshness is tracked via BaseRef::OwnGen rather than BaseDef::SubtreeGen, because references do not own subtrees.

Shares the same BRepGraph_CacheKind descriptors and BRepGraph_CacheKindRegistry as the node cache; the same kind GUID can address values in both caches.

OwnGen-based freshness

Each stored slot records OwnGen at write time. On read, if the stored OwnGen differs from the reference's current OwnGen the cached value is considered stale.

Lifecycle

NOT a Layer. Cleared on BRepGraph_Builder::Add() and Compact(). No explicit removal callback

Thread safety

After Reserve(), Get() and Set() for in-range indices bypass the mutex entirely. Out-of-range access falls back to mutex-protected vector growth.

Constructor & Destructor Documentation

◆ BRepGraph_RefTransientCache() [1/3]

BRepGraph_RefTransientCache::BRepGraph_RefTransientCache ( BRepGraph_RefTransientCache && theOther)
inlinenoexcept

Move constructor: transfers data, creates fresh mutex.

◆ BRepGraph_RefTransientCache() [2/3]

BRepGraph_RefTransientCache::BRepGraph_RefTransientCache ( )
default

◆ BRepGraph_RefTransientCache() [3/3]

BRepGraph_RefTransientCache::BRepGraph_RefTransientCache ( const BRepGraph_RefTransientCache & )
delete

Member Function Documentation

◆ Clear()

void BRepGraph_RefTransientCache::Clear ( )
noexcept

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

◆ CollectCacheKindSlots()

int BRepGraph_RefTransientCache::CollectCacheKindSlots ( const BRepGraph_RefId theRef,
const uint32_t theCurrentOwnGen,
int theSlots[] ) const

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

Parameters
[in]theRefreference to query
[in]theCurrentOwnGenfreshness 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_RefTransientCache::Get ( const BRepGraph_RefId theRef,
const int theKindSlot,
const uint32_t theCurrentOwnGen ) const

Retrieve a cached value using a pre-resolved kind slot index.

◆ Get() [2/2]

occ::handle< BRepGraph_CacheValue > BRepGraph_RefTransientCache::Get ( const BRepGraph_RefId theRef,
const occ::handle< BRepGraph_CacheKind > & theKind,
const uint32_t theCurrentOwnGen ) const

Retrieve a cached value for a reference and cache kind. Returns null handle if no value is stored or if OwnGen has changed.

◆ IsReserved()

bool BRepGraph_RefTransientCache::IsReserved ( ) const
inlinenoexcept

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

◆ operator=() [1/2]

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

Move assignment: transfers data, mutex stays local.

◆ operator=() [2/2]

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

◆ Remove() [1/2]

bool BRepGraph_RefTransientCache::Remove ( const BRepGraph_RefId theRef,
const int theKindSlot )

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

◆ Remove() [2/2]

bool BRepGraph_RefTransientCache::Remove ( const BRepGraph_RefId theRef,
const occ::handle< BRepGraph_CacheKind > & theKind )

Remove a cached value for a reference and cache kind.

◆ Reserve()

void BRepGraph_RefTransientCache::Reserve ( const int theKindCount,
const int theCounts[THE_REF_KIND_COUNT] )

Pre-allocate storage for lock-free parallel access.

◆ Set() [1/2]

void BRepGraph_RefTransientCache::Set ( const BRepGraph_RefId theRef,
const int theKindSlot,
const occ::handle< BRepGraph_CacheValue > & theValue,
const uint32_t theCurrentOwnGen )

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_RefTransientCache::Set ( const BRepGraph_RefId theRef,
const occ::handle< BRepGraph_CacheKind > & theKind,
const occ::handle< BRepGraph_CacheValue > & theValue,
const uint32_t theCurrentOwnGen )

Store a cached value for a reference 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_RefTransientCache::THE_DEFAULT_RESERVED_KIND_COUNT = 16
staticconstexpr

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

◆ THE_REF_KIND_COUNT

constexpr int BRepGraph_RefTransientCache::THE_REF_KIND_COUNT = 8
staticconstexpr

Number of BRepGraph_RefId::Kind enum values (Shell..Occurrence = 0..7).


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