semf
semf::app::TimeBase Class Referenceabstract

A TimeBase is the bridge between e.g. a hardware timer (interrupt service routine) and TickReceiver objects like /c SoftwareTimer. Multiple timers can be added to one TimeBase object, but one TickReceiver object can only be added to a single TimeBase. It's also not possible to add a TickReceiver object twice to a TimeBase. More...

#include <timebase.h>

Inheritance diagram for semf::app::TimeBase:
Inheritance graph
Collaboration diagram for semf::app::TimeBase:
Collaboration graph

Public Member Functions

virtual ~TimeBase ()=default
 
virtual void add (TickReceiver &tickReceiver)=0
 Adds e.g. a timer to this timebase. More...
 
virtual void remove (TickReceiver &tickReceiver)=0
 Removes e.g. a timer from this timebase. More...
 
virtual void enable (bool enable=true)=0
 Enables the TimeBase. More...
 
virtual void disable (bool disable=true)=0
 Disables the TimeBase. More...
 
virtual bool isEnabled () const =0
 Returns if the TimeBase is enabled. More...
 

Detailed Description

A TimeBase is the bridge between e.g. a hardware timer (interrupt service routine) and TickReceiver objects like /c SoftwareTimer. Multiple timers can be added to one TimeBase object, but one TickReceiver object can only be added to a single TimeBase. It's also not possible to add a TickReceiver object twice to a TimeBase.

When e.g. the hardware timer interrupt elapses, the count function of every previously added TickReceiver will be called in the order, the SoftwareTimer objects were added.

A TimeBase can easily be enabled or disabled. A disabled TimeBase does not call the timers count functions until it's enabled again.

Attention
: The count function must be called cyclically e.g. by a the interrupt service routine of a microcontroller.

Definition at line 35 of file timebase.h.

Constructor & Destructor Documentation

◆ ~TimeBase()

virtual semf::app::TimeBase::~TimeBase ( )
virtualdefault

Member Function Documentation

◆ add()

virtual void semf::app::TimeBase::add ( TickReceiver tickReceiver)
pure virtual

Adds e.g. a timer to this timebase.

Parameters
tickReceivere.g. /c SoftwareTimer or /c DigitalInPolling to add.

Implemented in semf::TimeBase.

Here is the caller graph for this function:

◆ disable()

virtual void semf::app::TimeBase::disable ( bool  disable = true)
pure virtual

Disables the TimeBase.

Parameters
disabletrue disables the TimeBase.
Note
Only an enabled timebase's timers counts and elapses.

Implemented in semf::TimeBase.

◆ enable()

virtual void semf::app::TimeBase::enable ( bool  enable = true)
pure virtual

Enables the TimeBase.

Parameters
enabletrue enables the TimeBase.
Note
Only an enabled timebase's timers counts and elapses.

Implemented in semf::TimeBase.

◆ isEnabled()

virtual bool semf::app::TimeBase::isEnabled ( ) const
pure virtual

Returns if the TimeBase is enabled.

Only a enabled timebase's timers count and elapse.

Returns
true for TimeBase enabled, otherwise false.

Implemented in semf::TimeBase.

◆ remove()

virtual void semf::app::TimeBase::remove ( TickReceiver tickReceiver)
pure virtual

Removes e.g. a timer from this timebase.

Parameters
tickReceivere.g. /c SoftwareTimer or /c DigitalInPolling to remove.

Implemented in semf::TimeBase.