semf
semf::TimeBase Class Reference

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::TimeBase:
Inheritance graph
Collaboration diagram for semf::TimeBase:
Collaboration graph

Public Member Functions

 TimeBase (app::Timer &timer, bool enable=false)
 Constructor. More...
 
 TimeBase (const TimeBase &other)=delete
 
void add (TickReceiver &tickReceiver) override
 Adds e.g. a timer to this TimeBase. More...
 
void remove (TickReceiver &tickReceiver) override
 Removes e.g. a timer from this TimeBase. More...
 
void enable (bool enable=true) override
 Enables the TimeBase. More...
 
void disable (bool disable=true) override
 Disables the TimeBase. More...
 
bool isEnabled () const override
 Returns if the TimeBase is enabled. More...
 
- Public Member Functions inherited from semf::app::TimeBase
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 23 of file timebase.h.

Constructor & Destructor Documentation

◆ TimeBase() [1/2]

semf::TimeBase::TimeBase ( app::Timer timer,
bool  enable = false 
)
explicit

Constructor.

Parameters
timerTimer interface (e.g. hardware timer).
enableEnables the TimeBase.

Definition at line 15 of file timebase.cpp.

Here is the call graph for this function:

◆ TimeBase() [2/2]

semf::TimeBase::TimeBase ( const TimeBase other)
explicitdelete

Member Function Documentation

◆ add()

void semf::TimeBase::add ( TickReceiver tickReceiver)
overridevirtual

Adds e.g. a timer to this TimeBase.

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

Implements semf::app::TimeBase.

Definition at line 22 of file timebase.cpp.

◆ disable()

void semf::TimeBase::disable ( bool  disable = true)
overridevirtual

Disables the TimeBase.

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

Implements semf::app::TimeBase.

Definition at line 37 of file timebase.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enable()

void semf::TimeBase::enable ( bool  enable = true)
overridevirtual

Enables the TimeBase.

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

Implements semf::app::TimeBase.

Definition at line 32 of file timebase.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isEnabled()

bool semf::TimeBase::isEnabled ( ) const
overridevirtual

Returns if the TimeBase is enabled.

Only a enabled timebase's timers count and elapse.

Returns
true for TimeBase enabled, otherwise false.

Implements semf::app::TimeBase.

Definition at line 42 of file timebase.cpp.

◆ remove()

void semf::TimeBase::remove ( TickReceiver tickReceiver)
overridevirtual

Removes e.g. a timer from this TimeBase.

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

Implements semf::app::TimeBase.

Definition at line 27 of file timebase.cpp.