FastLED 3.9.15
|
Thread-safe ID tracker that maps void* pointers to unique integer IDs.
Features:
Usage: IdTracker tracker; // Create instance int id = tracker.getOrCreateId(ptr); bool found = tracker.getId(ptr, &id); tracker.removeId(ptr);
For singleton behavior, wrap in your own singleton: static IdTracker& getGlobalTracker() { static IdTracker instance; return instance; }
Definition at line 30 of file id_tracker.h.
#include <id_tracker.h>
Public Member Functions | |
IdTracker ()=default | |
Default constructor - creates a new ID tracker instance. | |
IdTracker (const IdTracker &)=delete | |
IdTracker (IdTracker &&)=delete | |
void | clear () |
Clear all tracked pointers and reset ID counter. | |
bool | getId (void *ptr, int *outId) |
Get existing ID for pointer without creating a new one. | |
int | getOrCreateId (void *ptr) |
Get existing ID for pointer, or create a new one if not found. | |
IdTracker & | operator= (const IdTracker &)=delete |
IdTracker & | operator= (IdTracker &&)=delete |
bool | removeId (void *ptr) |
Remove tracking for a pointer. | |
size_t | size () |
Get the current number of tracked pointers. | |
Private Attributes | |
fl::mutex | mMutex |
int | mNextId = 0 |
fl::hash_map< void *, int > | mPointerToId |