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 94 of file assets-manager.h.


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