ezEngine Release 26.3
Loading...
Searching...
No Matches
ezDependencyTracker< Resource, Dependency > Class Template Reference

A thread-safe dependency tracking system for managing resource invalidation. More...

#include <DependencyTracker.h>

Public Member Functions

void AddResource (Resource *pResource, const ezSet< const Dependency * > &dependencies)
 Adds a resource and its dependencies to the tracking system.
 
void RemoveResource (Resource *pResource)
 Removes a resource from the tracking system.
 
void DependencyDestroyed (Dependency *pDependency)
 Notifies the tracker that a dependency has been destroyed.
 

Public Attributes

ezEvent< Resource * > m_ResourceInvalidatedEvent
 Event that is broadcast when a resource becomes invalid due to dependency destruction.
 

Detailed Description

template<typename Resource, typename Dependency>
class ezDependencyTracker< Resource, Dependency >

A thread-safe dependency tracking system for managing resource invalidation.

This template class tracks dependencies between resources and their dependencies to allow invalidating resources when their dependencies are destroyed. When a dependency is destroyed, all resources that depend on it are automatically identified and an invalidation event is broadcast for each affected resource.

Template Parameters
ResourceThe type of resource being tracked (e.g. bind groups)
DependencyThe base type of the dependencies (e.g., ezGALResource)

Member Function Documentation

◆ AddResource()

template<typename Resource , typename Dependency >
void ezDependencyTracker< Resource, Dependency >::AddResource ( Resource *  pResource,
const ezSet< const Dependency * > &  dependencies 
)

Adds a resource and its dependencies to the tracking system.

This method registers a resource along with all of its dependencies. The resource will be automatically invalidated if any of its dependencies are destroyed. Each resource can only be added once - attempting to add the same resource again will trigger an assertion in debug builds.

Parameters
pResourcePointer to the resource to track
dependenciesSet of dependencies that this resource depends on

◆ DependencyDestroyed()

template<typename Resource , typename Dependency >
void ezDependencyTracker< Resource, Dependency >::DependencyDestroyed ( Dependency *  pDependency)

Notifies the tracker that a dependency has been destroyed.

This method should be called when a dependency object is about to be destroyed. It will identify all resources that depend on this dependency, remove the dependency relationships, and broadcast invalidation events for each affected resource.

Parameters
pDependencyPointer to the dependency that is being destroyed

◆ RemoveResource()

template<typename Resource , typename Dependency >
void ezDependencyTracker< Resource, Dependency >::RemoveResource ( Resource *  pResource)

Removes a resource from the tracking system.

This method removes the resource and all of its dependency relationships from the tracker. The resource will no longer receive invalidation events even if its former dependencies are destroyed.

Parameters
pResourcePointer to the resource to remove from tracking

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