The Sparta Modeling Framework
|
Callback for observation-state of a NotificationSourceBase. More...
#include <NotificationSource.hpp>
Public Member Functions | |
ObservationStateCallback (NotificationSourceBase &ns, ObservationStateChange type, callback_t callback) | |
ObservationStateCallback (const ObservationStateCallback &)=delete | |
ObservationStateCallback (ObservationStateCallback &&)=delete | |
ObservationStateCallback & | operator= (const ObservationStateCallback &)=delete |
ObservationStateChange | getType () const |
Get tyhe type of change associated with this callback instance. | |
void | operator() (NotificationSourceBase const &ns, uint32_t observers) const |
Invoked the callback function. | |
void | dump (std::ostream &o) const |
Dump string description to an ostream. | |
Callback for observation-state of a NotificationSourceBase.
Use this to monitor changes in the observation state of a NotificationSource and bind some change to a callable. This object automatically binds the callback function to the notification source on construction and removes the callback on destruction. If the notification source is destroyed before this callback object, then the callback will never be invoked again and it will not attempt to deregister when eventually destroyed.
The intent of this feature is for some model to monitor the observation of some of its constituent notifications for both their lifetimes (which are hopefully the same). Creating and removing these callbacks throughout a simulation is not expected. An example use case is needing to change the state of a JIT model if someone is now observing some detail of execution (e.g. an instruction executed notification)
* class X{ * public: * NotificationSource<MyPayload> ns; * NotificationSource::ObservationStateCallback nscb; * MyConstructor(node) * : ns(node, ....), * nscb(ns, NotificationSourceBase::ObservationStateChange::SOLE_OBSERVER_REGISTERING, handleSoleObserverAdded_) * {} * void handleSoleObserverAdded_(NotificationSourceBase const & source, uint32_t new_observer_count) { * { ... } * } * *
Definition at line 160 of file NotificationSource.hpp.
|
inline |
Definition at line 169 of file NotificationSource.hpp.
|
inline |
Definition at line 180 of file NotificationSource.hpp.
|
inline |
Dump string description to an ostream.
Definition at line 209 of file NotificationSource.hpp.
|
inline |
Get tyhe type of change associated with this callback instance.
Definition at line 195 of file NotificationSource.hpp.
|
inline |
Invoked the callback function.
Definition at line 200 of file NotificationSource.hpp.