Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
Flint::AssetManager::WatchHandle Class Reference

RAII handle returned by watch(). More...

#include <flint/resource/assets-manager.h>

+ Collaboration diagram for Flint::AssetManager::WatchHandle:

Public Member Functions

 WatchHandle ()=default
 Construct an empty (inactive) handle.
 
 WatchHandle (AssetManager *manager, uint64_t id, std::weak_ptr< ManagerLifetime > managerLifetime)
 Construct an active handle tied to a specific watch entry.
 
 ~WatchHandle ()
 Destructor; calls reset() to cancel the watch if still active.
 
 WatchHandle (WatchHandle &&other) noexcept
 Move constructor; transfers ownership and nulls the source.
 
WatchHandle & operator= (WatchHandle &&other) noexcept
 Move-assignment operator.
 
 WatchHandle (const WatchHandle &)=delete
 
WatchHandle & operator= (const WatchHandle &)=delete
 
bool isActive () const
 Return whether this handle is still registered.
 
void reset ()
 Cancel the watch and release the handle.
 

Detailed Description

RAII handle returned by watch().

While a WatchHandle is alive the associated callback remains registered. Destroying or resetting the handle automatically deregisters it. Handles are move-only; they cannot be copied.

Example

// Callback fires whenever "textures/hero.png" is reloaded.
auto handle = assets.watch("textures/hero.png", [&](const std::string &path) {
reloadHeroSprite();
});
// handle goes out of scope → watch is cancelled automatically.

Definition at line 95 of file assets-manager.h.

Constructor & Destructor Documentation

◆ WatchHandle() [1/2]

Flint::AssetManager::WatchHandle::WatchHandle ( AssetManager * manager,
uint64_t id,
std::weak_ptr< ManagerLifetime > managerLifetime )
inline

Construct an active handle tied to a specific watch entry.

Parameters
managerOwning AssetManager.
idUnique watch identifier.
managerLifetimeWeak pointer to the manager's lifetime token.

Definition at line 107 of file assets-manager.h.

◆ ~WatchHandle()

Flint::AssetManager::WatchHandle::~WatchHandle ( )
inline

Destructor; calls reset() to cancel the watch if still active.

Definition at line 115 of file assets-manager.h.

◆ WatchHandle() [2/2]

Flint::AssetManager::WatchHandle::WatchHandle ( WatchHandle && other)
inlinenoexcept

Move constructor; transfers ownership and nulls the source.

Definition at line 120 of file assets-manager.h.

Member Function Documentation

◆ isActive()

bool Flint::AssetManager::WatchHandle::isActive ( ) const
inlinenodiscard

Return whether this handle is still registered.

Returns false once reset() has been called or the owning AssetManager has been destroyed.

Returns
true if the watch is active.

Definition at line 157 of file assets-manager.h.

◆ operator=()

WatchHandle & Flint::AssetManager::WatchHandle::operator= ( WatchHandle && other)
inlinenoexcept

Move-assignment operator.

Cancels any existing watch on *this before taking ownership from other.

Definition at line 133 of file assets-manager.h.

◆ reset()

void Flint::AssetManager::WatchHandle::reset ( )
inline

Cancel the watch and release the handle.

Safe to call more than once; subsequent calls are no-ops.

Definition at line 166 of file assets-manager.h.


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