PhoenixClock  0.4.0
Library wrapping the usage of system's clock, allowing to use clock mock-ups
Loading...
Searching...
No Matches
PGenericClock< _TBackend, _TMockBackend > Class Template Reference

Generic clock which can use several backends (real clock backend and a mock of clock) More...

#include <PGenericClock.h>

Public Member Functions

PClockMode::PClockMode getMode () const
 Get the mode of the PGenericClock (NO_MOCK, MOCK or MOCK_RECORD)
 
time_t now ()
 Get the current time of the clock.
 
PGenericClockoperator= (const PGenericClock< _TBackend, _TMockBackend > &other)
 Definition of equal operator of PGenericClock.
 
 PGenericClock ()
 Default constructor of PGenericClock.
 
 PGenericClock (const PGenericClock< _TBackend, _TMockBackend > &other)
 Copy constructor of PGenericClock.
 
void setMode (PClockMode::PClockMode mode)
 Set the mode of the PGenericClock (NO_MOCK, MOCK or MOCK_RECORD)
 
virtual ~PGenericClock ()
 Destructor of PGenericClock.
 

Protected Member Functions

void copyPGenericClock (const PGenericClock< _TBackend, _TMockBackend > &other)
 Copy function of PGenericClock.
 

Private Member Functions

void initialisationPGenericClock ()
 Initialisation function of the class PGenericClock.
 

Private Attributes

_TBackend p_clockBackend
 Instance of the clock backend (necessary for some clock backends)
 
_TMockBackend p_mockBackend
 Instance of the clock backend (necessary for some clock backends)
 
PClockMode::PClockMode p_mode
 Mode of the Clock (no mock, mock, mock_record)
 

Detailed Description

template<typename _TBackend, typename _TMockBackend>
class PGenericClock< _TBackend, _TMockBackend >

Generic clock which can use several backends (real clock backend and a mock of clock)

Definition at line 17 of file PGenericClock.h.

Constructor & Destructor Documentation

◆ PGenericClock() [1/2]

template<typename _TBackend, typename _TMockBackend>
PGenericClock< _TBackend, _TMockBackend >::PGenericClock ( )

Default constructor of PGenericClock.

Definition at line 16 of file PGenericClock_impl.h.

16 {
18}
void initialisationPGenericClock()
Initialisation function of the class PGenericClock.

References initialisationPGenericClock().

Referenced by copyPGenericClock(), operator=(), and PGenericClock().

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

◆ PGenericClock() [2/2]

template<typename _TBackend, typename _TMockBackend>
PGenericClock< _TBackend, _TMockBackend >::PGenericClock ( const PGenericClock< _TBackend, _TMockBackend > & other)

Copy constructor of PGenericClock.

Parameters
other: class to copy

Definition at line 24 of file PGenericClock_impl.h.

24 {
26}
Generic clock which can use several backends (real clock backend and a mock of clock)
void copyPGenericClock(const PGenericClock< _TBackend, _TMockBackend > &other)
Copy function of PGenericClock.

References copyPGenericClock(), and PGenericClock().

+ Here is the call graph for this function:

◆ ~PGenericClock()

template<typename _TBackend, typename _TMockBackend>
PGenericClock< _TBackend, _TMockBackend >::~PGenericClock ( )
virtual

Destructor of PGenericClock.

Definition at line 30 of file PGenericClock_impl.h.

30 {
31
32}

Member Function Documentation

◆ copyPGenericClock()

template<typename _TBackend, typename _TMockBackend>
void PGenericClock< _TBackend, _TMockBackend >::copyPGenericClock ( const PGenericClock< _TBackend, _TMockBackend > & other)
protected

Copy function of PGenericClock.

Parameters
other: class to copy

Definition at line 80 of file PGenericClock_impl.h.

80 {
82}
PClockMode::PClockMode p_mode
Mode of the Clock (no mock, mock, mock_record)

References p_mode, and PGenericClock().

Referenced by operator=(), and PGenericClock().

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

◆ getMode()

template<typename _TBackend, typename _TMockBackend>
PClockMode::PClockMode PGenericClock< _TBackend, _TMockBackend >::getMode ( ) const

Get the mode of the PGenericClock (NO_MOCK, MOCK or MOCK_RECORD)

Returns
mode of the PGenericClock

Definition at line 56 of file PGenericClock_impl.h.

56 {
57 return p_mode;
58}

References p_mode.

◆ initialisationPGenericClock()

template<typename _TBackend, typename _TMockBackend>
void PGenericClock< _TBackend, _TMockBackend >::initialisationPGenericClock ( )
private

Initialisation function of the class PGenericClock.

Definition at line 86 of file PGenericClock_impl.h.

86 {
88}

References PClockMode::NO_MOCK, and p_mode.

Referenced by PGenericClock().

+ Here is the caller graph for this function:

◆ now()

template<typename _TBackend, typename _TMockBackend>
time_t PGenericClock< _TBackend, _TMockBackend >::now ( )

Get the current time of the clock.

Returns
current time of the clock (the unit is given by the used backend, second for clock, ns for system_clock, etc)

Definition at line 64 of file PGenericClock_impl.h.

64 {
66 return p_clockBackend.now();
67 }else if(p_mode == PClockMode::MOCK){
68 return p_mockBackend.now();
69 }else{
71 p_mockBackend.setCurrentTime(currentTime);
72 return currentTime;
73 }
74}
_TBackend p_clockBackend
Instance of the clock backend (necessary for some clock backends)
_TMockBackend p_mockBackend
Instance of the clock backend (necessary for some clock backends)

References PClockMode::MOCK, PClockMode::NO_MOCK, p_clockBackend, p_mockBackend, and p_mode.

◆ operator=()

template<typename _TBackend, typename _TMockBackend>
PGenericClock< _TBackend, _TMockBackend > & PGenericClock< _TBackend, _TMockBackend >::operator= ( const PGenericClock< _TBackend, _TMockBackend > & other)

Definition of equal operator of PGenericClock.

Parameters
other: class to copy
Returns
copied class

Definition at line 39 of file PGenericClock_impl.h.

39 {
41 return *this;
42}

References copyPGenericClock(), and PGenericClock().

+ Here is the call graph for this function:

◆ setMode()

template<typename _TBackend, typename _TMockBackend>
void PGenericClock< _TBackend, _TMockBackend >::setMode ( PClockMode::PClockMode mode)

Set the mode of the PGenericClock (NO_MOCK, MOCK or MOCK_RECORD)

Parameters
mode: mode of the PGenericClock

Definition at line 48 of file PGenericClock_impl.h.

48 {
49 p_mode = mode;
50}

References p_mode.

Member Data Documentation

◆ p_clockBackend

template<typename _TBackend, typename _TMockBackend>
_TBackend PGenericClock< _TBackend, _TMockBackend >::p_clockBackend
private

Instance of the clock backend (necessary for some clock backends)

Definition at line 37 of file PGenericClock.h.

Referenced by now().

◆ p_mockBackend

template<typename _TBackend, typename _TMockBackend>
_TMockBackend PGenericClock< _TBackend, _TMockBackend >::p_mockBackend
private

Instance of the clock backend (necessary for some clock backends)

Definition at line 39 of file PGenericClock.h.

Referenced by now().

◆ p_mode

template<typename _TBackend, typename _TMockBackend>
PClockMode::PClockMode PGenericClock< _TBackend, _TMockBackend >::p_mode
private

Mode of the Clock (no mock, mock, mock_record)

Definition at line 35 of file PGenericClock.h.

Referenced by copyPGenericClock(), getMode(), initialisationPGenericClock(), now(), and setMode().


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