CppUtils::UnitTest::EventWatcher<String::Hasher eventName, class... Args>
CLASSThread-safe RAII observer for monitoring emitted events and collecting payloads.
Description
Section intitulée « Description »Subscribes to the designated event upon construction and unsubscribes automatically upon destruction. Provides blocking synchronization utilities (waitForEvent, waitForOccurrences) and thread-safe inspection of occurrence counts and captured payloads.
| Paramètre template | Description |
|---|---|
eventName | Compile-time hashed string identifying the event. |
Args | Types of the event payload arguments. |
Types publics
Section intitulée « Types publics »using CppUtils::UnitTest::EventWatcher<eventName, Args>::Payload = std::conditional_t<sizeof...(Args) == 0, std::monostate, std::conditional_t<sizeof...(Args) == 1, std::tuple_element_t<0, std::tuple<Args..., void>>, std::tuple<Args...>>>;Méthodes publiques
Section intitulée « Méthodes publiques »Subscribes the watcher to the specified event emitter.
| Paramètre | Description |
|---|---|
emitter | Reference to the event emitter to monitor. |
Returns the total number of times the monitored event has been fired.
Retourne : Event occurrence count.
Checks if the monitored event has occurred at least once.
Retourne : True if count() > 0.
template <Chrono::Duration TimeoutDuration = std::chrono::milliseconds>auto EventWatcher::waitForOccurrences(std::size_t targetCount, TimeoutDuration timeout = std::chrono::milliseconds{1000}) -> bool;Blocks until the event has been fired at least targetCount times or timeout expires.
| Paramètre template | Description |
|---|---|
TimeoutDuration | Duration type (defaults to std::chrono::milliseconds). |
| Paramètre | Description |
|---|---|
targetCount | Number of occurrences to wait for. |
timeout | Maximum duration to wait before giving up. |
Retourne : True if the target occurrence count was reached before the timeout expired.
template <Chrono::Duration TimeoutDuration = std::chrono::milliseconds>auto EventWatcher::waitForEvent(TimeoutDuration timeout = std::chrono::milliseconds{1000}) -> bool;Blocks until the event occurs at least once or timeout expires.
| Paramètre template | Description |
|---|---|
TimeoutDuration | Duration type (defaults to std::chrono::milliseconds). |
| Paramètre | Description |
|---|---|
timeout | Maximum duration to wait before giving up. |
Retourne : True if the event occurred before the timeout expired.
Acquires exclusive locked access to the recorded state and payloads.
Retourne : Unique accessor locking the internal state.