DetectorGraph  2.0
Public Member Functions | Protected Attributes | List of all members
DetectorGraph::TimeoutPublisher< T > Class Template Reference

Push data to a topic when timer expires. More...

Collaboration diagram for DetectorGraph::TimeoutPublisher< T >:

Public Member Functions

 TimeoutPublisher ()
 Basic Constructor. More...
 
void SetTimeoutService (TimeoutPublisherService *apTimeoutPublisherService)
 Sets the timeout service and acquires a TimerHandle to be used by the default/simple API. More...
 
virtual ~TimeoutPublisher ()
 Empty Virtual Destructor. More...
 
void PublishOnTimeout (const T &aData, const uint64_t aMillisecondsFromNow, TimeoutPublisherHandle aTimerId=kInvalidTimeoutPublisherHandle)
 Schedules a TopicState for Publishing after a timeout. More...
 
void CancelPublishOnTimeout (TimeoutPublisherHandle aTimerId=kInvalidTimeoutPublisherHandle)
 Cancels the Scheduled PublishOnTimeout. More...
 
bool HasTimeoutExpired (TimeoutPublisherHandle aTimerId=kInvalidTimeoutPublisherHandle) const
 Returns weather a timeout has expired or not. More...
 

Protected Attributes

TimeoutPublisherServicempTimeoutPublisherService
 
TimeoutPublisherHandle mDefaultHandle
 

Detailed Description

template<class T>
class DetectorGraph::TimeoutPublisher< T >

Push data to a topic when timer expires.

TimeoutPublisher provides a mechanism to schedule the publishing of a TopicState to the graph in the future. Similarly to FuturePublisher, the published TopicState goes into a separate (future) evaluation and so toposort constraints do not apply; this allows a detector to publish to itself.

Additionally the detector can cancel/reset a scheduled job.

Example:

class HeartbeatDetector : public Detector,
public SubscriberInterface<HeartBeat>,
public TimeoutPublisher<HeartBeat>
{
HeartbeatDetector(Graph* graph, TimeoutPublisherService* apTimeoutService) : Detector(graph)
{
Subscribe<HeartBeat>(this);
SetupTimeoutPublishing<HeartBeat>(this, apTimeoutService);
}
void Evaluate(const HeartBeat&)
{
// This will be evaluated at 1Hz
PublishOnTimeout(HeartBeat(), 1000);
}
}

Definition at line 57 of file timeoutpublisher.hpp.

Constructor & Destructor Documentation

◆ TimeoutPublisher()

template<class T>
DetectorGraph::TimeoutPublisher< T >::TimeoutPublisher ( )
inline

Basic Constructor.

This constructor does not fully initialize the TimeoutPublisher as a TimeoutPublisherService is needed. That's done by SetTimeoutService.

Definition at line 66 of file timeoutpublisher.hpp.

◆ ~TimeoutPublisher()

template<class T>
virtual DetectorGraph::TimeoutPublisher< T >::~TimeoutPublisher ( )
inlinevirtual

Empty Virtual Destructor.

Definition at line 84 of file timeoutpublisher.hpp.

Member Function Documentation

◆ CancelPublishOnTimeout()

template<class T>
void DetectorGraph::TimeoutPublisher< T >::CancelPublishOnTimeout ( TimeoutPublisherHandle  aTimerId = kInvalidTimeoutPublisherHandle)
inline

Cancels the Scheduled PublishOnTimeout.

Definition at line 108 of file timeoutpublisher.hpp.

◆ HasTimeoutExpired()

template<class T>
bool DetectorGraph::TimeoutPublisher< T >::HasTimeoutExpired ( TimeoutPublisherHandle  aTimerId = kInvalidTimeoutPublisherHandle) const
inline

Returns weather a timeout has expired or not.

Definition at line 118 of file timeoutpublisher.hpp.

◆ PublishOnTimeout()

template<class T>
void DetectorGraph::TimeoutPublisher< T >::PublishOnTimeout ( const T &  aData,
const uint64_t  aMillisecondsFromNow,
TimeoutPublisherHandle  aTimerId = kInvalidTimeoutPublisherHandle 
)
inline

Schedules a TopicState for Publishing after a timeout.

This method is analogous to Publish() in the sense that it's a Detector output but with two big differences:

  • Parameters
    aDatais only published after
    aMillisecondsFromNow
  • Parameters
    aDatais published to the Graph Input queue instead of another topic so TopoSort constraints do not apply; this allows a detector to publish and subscribe to the same topic.
    aTimerId(optional) allows detectors to control multiple concurrent timers. TimeoutPublisherHandles are vended through TimeoutPublisherService::GetUniqueTimerHandle

Definition at line 98 of file timeoutpublisher.hpp.

◆ SetTimeoutService()

template<class T>
void DetectorGraph::TimeoutPublisher< T >::SetTimeoutService ( TimeoutPublisherService apTimeoutPublisherService)
inline

Sets the timeout service and acquires a TimerHandle to be used by the default/simple API.

Definition at line 75 of file timeoutpublisher.hpp.

Member Data Documentation

◆ mDefaultHandle

template<class T>
TimeoutPublisherHandle DetectorGraph::TimeoutPublisher< T >::mDefaultHandle
protected

Definition at line 128 of file timeoutpublisher.hpp.

◆ mpTimeoutPublisherService

template<class T>
TimeoutPublisherService* DetectorGraph::TimeoutPublisher< T >::mpTimeoutPublisherService
protected

Definition at line 127 of file timeoutpublisher.hpp.


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