DetectorGraph
2.0
|
A service that provides Timer function to DetectorGraph Detectors. More...
Public Member Functions | |
TimeoutPublisherService (Graph &graph) | |
Constructor that initializes the service connected to a graph. More... | |
virtual | ~TimeoutPublisherService () |
Destructor. More... | |
void | StartPeriodicPublishing () |
Starts a Metronome to publish scheduled TopicStates. More... | |
TimeoutPublisherHandle | GetUniqueTimerHandle () |
Returns a unique id/handle for a new timer. More... | |
template<class T > | |
void | SchedulePeriodicPublishing (const TimeOffset aPeriodInMilliseconds) |
Schedules a TopicState for publishing periodically. More... | |
template<class T > | |
void | ScheduleTimeout (const T &aData, const TimeOffset aMillisecondsFromNow, const TimeoutPublisherHandle aTimerHandle) |
Schedules a TopicState for Publishing after a timeout. More... | |
void | CancelPublishOnTimeout (const TimeoutPublisherHandle aTimerHandle) |
Cancels a timeout and deletes the stored TopicState. More... | |
bool | HasTimeoutExpired (const TimeoutPublisherHandle aTimerHandle) const |
Returns weather the timeout for a given handle has expired/fired already. More... | |
virtual TimeOffset | GetTime () const =0 |
Should return the time offset to Epoch. More... | |
virtual TimeOffset | GetMonotonicTime () const =0 |
Should return monotonic time since some unspecified starting point. More... | |
Protected Member Functions | |
void | TimeoutExpired (const TimeoutPublisherHandle aTimerHandle) |
Fires/Dispatches a TopicState that was pending on a timeout. More... | |
virtual void | SetTimeout (const TimeOffset aMillisecondsFromNow, const TimeoutPublisherHandle)=0 |
Should setup a timeout for the given handle. More... | |
virtual void | Start (const TimeoutPublisherHandle)=0 |
Should start a timer for the given handle. More... | |
virtual void | Cancel (const TimeoutPublisherHandle)=0 |
Should cancel the timer the given handle. More... | |
void | MetronomeFired () |
Update metronome counters and Fires/Dispatches TopicStates that was pending on scheduled period. More... | |
virtual void | StartMetronome (const TimeOffset aPeriodInMilliseconds)=0 |
Should start the metronome (periodic timer) for the given period. More... | |
virtual void | CancelMetronome ()=0 |
Should stop the metronome. More... | |
A service that provides Timer function to DetectorGraph Detectors.
TimeoutPublisherService is used/shared among many TimeoutPublishers (Detectors) to add the notion of timed publications to DetectorGraph.
Definition at line 48 of file timeoutpublisherservice.hpp.
DetectorGraph::TimeoutPublisherService::TimeoutPublisherService | ( | Graph & | graph | ) |
Constructor that initializes the service connected to a graph.
[in] | graph | The graph to which timed out TopicStates will be posted |
Definition at line 20 of file timeoutpublisherservice.cpp.
|
virtual |
Destructor.
Deletes all dynamically allocated pending TopicStates
Definition at line 24 of file timeoutpublisherservice.cpp.
|
protectedpure virtual |
Should cancel the timer the given handle.
This must be implemented by subclasses. This should cancel the timer.
Implemented in DetectorGraph::TestTimeoutPublisherService.
|
protectedpure virtual |
Should stop the metronome.
This must be implemented by subclasses. This should stop the periodic timer.
Implemented in DetectorGraph::TestTimeoutPublisherService.
void DetectorGraph::TimeoutPublisherService::CancelPublishOnTimeout | ( | const TimeoutPublisherHandle | aTimerHandle | ) |
Cancels a timeout and deletes the stored TopicState.
This is called by different TimeoutPublishers when a timeout must be canceled.
Definition at line 78 of file timeoutpublisherservice.cpp.
|
pure virtual |
Should return monotonic time since some unspecified starting point.
This must be implemented by subclasses. Returns the time offset to an unspecified point back in time that should not change for the duration of this instance. Different detectors may call this to acquire a consistent, strictly increasing, time offset valid for the duration of this object's instance.
Implemented in DetectorGraph::TestTimeoutPublisherService.
|
pure virtual |
Should return the time offset to Epoch.
This must be implemented by subclasses. Different detectors may call this to acquire a timestamp - usually used to "stamp" a TopicState. This clock may jump back & forth due to time sync.
Implemented in DetectorGraph::TestTimeoutPublisherService.
TimeoutPublisherHandle DetectorGraph::TimeoutPublisherService::GetUniqueTimerHandle | ( | ) |
Returns a unique id/handle for a new timer.
Different TimeoutPublishers will call this to 'acquire' a timer. The handle is then used throughout the API to refer to any individual timer. Note that this will never return kInvalidTimeoutPublisherHandle.
Definition at line 44 of file timeoutpublisherservice.cpp.
bool DetectorGraph::TimeoutPublisherService::HasTimeoutExpired | ( | const TimeoutPublisherHandle | aTimerHandle | ) | const |
Returns weather the timeout for a given handle has expired/fired already.
This will also return true if the referred timer never existed.
Definition at line 116 of file timeoutpublisherservice.cpp.
|
protected |
Update metronome counters and Fires/Dispatches TopicStates that was pending on scheduled period.
This method should be called by a particular subclasses of TimeoutPublisherService to notify the service that the actual internal period timer has fired.
Definition at line 135 of file timeoutpublisherservice.cpp.
|
inline |
Schedules a TopicState for publishing periodically.
This is called by different Detectors with a TopicState and a publishing period. This method updates the metronome period based on the GCD of the requested publishing period. Calling 'StartPeriodicPublishing' will start publishing T
to the graph periodically with interval
aPeriodInMilliseconds | . |
aPeriodInMilliseconds | The regular period at which T should be published. |
Definition at line 154 of file timeoutpublisherservice.hpp.
|
inline |
Schedules a TopicState for Publishing after a timeout.
This is called internally by TimeoutPublishers. It starts a timer set to expire at a given deadline. When the deadline is reached
aData | is Published to the graph. Calling this method on an pending |
aTimerHandle | resets it (canceling any previous timeouts) |
aData | The TopicState to be published when the deadline expires. |
aMillisecondsFromNow | The deadline relative to now. |
aTimerHandle | A unique handle for this timer. |
Definition at line 184 of file timeoutpublisherservice.hpp.
|
protectedpure virtual |
Should setup a timeout for the given handle.
This must be implemented by subclasses. This should initialize a unique timer for that handle (if it doesn't already exist) and set it's timeout accordingly.
Implemented in DetectorGraph::TestTimeoutPublisherService.
|
protectedpure virtual |
Should start a timer for the given handle.
This must be implemented by subclasses. This should start the timer.
Implemented in DetectorGraph::TestTimeoutPublisherService.
|
protectedpure virtual |
Should start the metronome (periodic timer) for the given period.
This must be implemented by subclasses. This should start the periodic timer.
Implemented in DetectorGraph::TestTimeoutPublisherService.
void DetectorGraph::TimeoutPublisherService::StartPeriodicPublishing | ( | ) |
Starts a Metronome to publish scheduled TopicStates.
Calling this method starts a metronome(periodic timer). TimeoutPublisherService will start publishing scheduled TopicStates periodically to graph.
Definition at line 124 of file timeoutpublisherservice.cpp.
|
protected |
Fires/Dispatches a TopicState that was pending on a timeout.
This method should be called by a particular subclasses of TimeoutPublisherService to notify the service that the actual internal timers have expired/fired.
Definition at line 98 of file timeoutpublisherservice.cpp.