DetectorGraph  2.0
Classes | Public Member Functions | Protected Member Functions | List of all members
DetectorGraph::TimeoutPublisherService Class Referenceabstract

A service that provides Timer function to DetectorGraph Detectors. More...

Collaboration diagram for DetectorGraph::TimeoutPublisherService:

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ TimeoutPublisherService()

DetectorGraph::TimeoutPublisherService::TimeoutPublisherService ( Graph graph)

Constructor that initializes the service connected to a graph.

Parameters
[in]graphThe graph to which timed out TopicStates will be posted

Definition at line 20 of file timeoutpublisherservice.cpp.

◆ ~TimeoutPublisherService()

DetectorGraph::TimeoutPublisherService::~TimeoutPublisherService ( )
virtual

Destructor.

Deletes all dynamically allocated pending TopicStates

Definition at line 24 of file timeoutpublisherservice.cpp.

Member Function Documentation

◆ Cancel()

virtual void DetectorGraph::TimeoutPublisherService::Cancel ( const TimeoutPublisherHandle  )
protectedpure virtual

Should cancel the timer the given handle.

This must be implemented by subclasses. This should cancel the timer.

Implemented in DetectorGraph::TestTimeoutPublisherService.

◆ CancelMetronome()

virtual void DetectorGraph::TimeoutPublisherService::CancelMetronome ( )
protectedpure virtual

Should stop the metronome.

This must be implemented by subclasses. This should stop the periodic timer.

Implemented in DetectorGraph::TestTimeoutPublisherService.

◆ CancelPublishOnTimeout()

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.

◆ GetMonotonicTime()

virtual TimeOffset DetectorGraph::TimeoutPublisherService::GetMonotonicTime ( ) const
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.

◆ GetTime()

virtual TimeOffset DetectorGraph::TimeoutPublisherService::GetTime ( ) const
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.

◆ GetUniqueTimerHandle()

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.

◆ HasTimeoutExpired()

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.

◆ MetronomeFired()

void DetectorGraph::TimeoutPublisherService::MetronomeFired ( )
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.

◆ SchedulePeriodicPublishing()

template<class T >
void DetectorGraph::TimeoutPublisherService::SchedulePeriodicPublishing ( const TimeOffset  aPeriodInMilliseconds)
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

Parameters
aPeriodInMilliseconds.
aPeriodInMillisecondsThe regular period at which T should be published.

Definition at line 154 of file timeoutpublisherservice.hpp.

◆ ScheduleTimeout()

template<class T >
void DetectorGraph::TimeoutPublisherService::ScheduleTimeout ( const T &  aData,
const TimeOffset  aMillisecondsFromNow,
const TimeoutPublisherHandle  aTimerHandle 
)
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

Parameters
aDatais Published to the graph. Calling this method on an pending
aTimerHandleresets it (canceling any previous timeouts)
aDataThe TopicState to be published when the deadline expires.
aMillisecondsFromNowThe deadline relative to now.
aTimerHandleA unique handle for this timer.

Definition at line 184 of file timeoutpublisherservice.hpp.

◆ SetTimeout()

virtual void DetectorGraph::TimeoutPublisherService::SetTimeout ( const TimeOffset  aMillisecondsFromNow,
const TimeoutPublisherHandle   
)
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.

◆ Start()

virtual void DetectorGraph::TimeoutPublisherService::Start ( const TimeoutPublisherHandle  )
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.

◆ StartMetronome()

virtual void DetectorGraph::TimeoutPublisherService::StartMetronome ( const TimeOffset  aPeriodInMilliseconds)
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.

◆ StartPeriodicPublishing()

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.

◆ TimeoutExpired()

void DetectorGraph::TimeoutPublisherService::TimeoutExpired ( const TimeoutPublisherHandle  aTimerHandle)
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.


The documentation for this class was generated from the following files: