|
ORE Studio 0.0.4
|
Tracks recently-modified records for recency highlighting. More...
#include <RecencyTracker.hpp>

Public Member Functions | |
| RecencyTracker (KeyExtractor key_extractor) | |
| Construct a RecencyTracker with custom key extractor. | |
| RecencyTracker (KeyExtractor key_extractor, TimestampExtractor timestamp_extractor) | |
| Construct a RecencyTracker with custom key and timestamp extractors. | |
| template<typename Container > | |
| bool | update (const Container &entities) |
| Update the set of recent records by comparing timestamps. | |
| bool | is_recent (const std::string &key) const |
| Check if a record with the given key is recent. | |
| std::size_t | recent_count () const |
| Get the number of recent records. | |
| bool | has_recent () const |
| Check if there are any recent records. | |
| void | clear () |
| Clear the recent records set. | |
| void | reset () |
| Reset the tracker completely. | |
Tracks recently-modified records for recency highlighting.
This template class provides a reusable way to detect which records have been modified since the last reload. It compares each record's recorded_at timestamp against the last reload time and tracks their identifiers.
| Entity | The entity type (e.g., catalog, currency) |
| KeyExtractor | A callable that extracts the identifier from an entity. Signature: std::string(const Entity&) |
| TimestampExtractor | A callable that extracts the recorded_at timestamp. Signature: std::chrono::system_clock::time_point(const Entity&) Defaults to accessing .recorded_at member. |
Usage:
|
explicit |
Construct a RecencyTracker with custom key extractor.
Uses the default timestamp extractor (entity.recorded_at).
| key_extractor | Callable to extract identifier from entity |
| RecencyTracker | ( | KeyExtractor | key_extractor, |
| TimestampExtractor | timestamp_extractor | ||
| ) |
Construct a RecencyTracker with custom key and timestamp extractors.
| key_extractor | Callable to extract identifier from entity |
| timestamp_extractor | Callable to extract recorded_at from entity |
| bool update | ( | const Container & | entities | ) |
Update the set of recent records by comparing timestamps.
Compares each entity's recorded_at against the last reload time. On first call, sets the baseline timestamp without marking anything recent.
| entities | The collection of entities to check |
| bool is_recent | ( | const std::string & | key | ) | const |
Check if a record with the given key is recent.
| key | The identifier to check |
| void clear | ( | ) |
Clear the recent records set.
Call this when pulsing completes.
| void reset | ( | ) |
Reset the tracker completely.
Clears recent keys and resets the last reload time.