PhoenixClockMock  2.0.0
Tool to manipulate mock of clock (split, merge and get info)
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) More...
 
time_t now ()
 Get the current time of the clock. More...
 
PGenericClockoperator= (const PGenericClock< _TBackend, _TMockBackend > &other)
 Definition of equal operator of PGenericClock. More...
 
 PGenericClock ()
 Default constructor of PGenericClock. More...
 
 PGenericClock (const PGenericClock< _TBackend, _TMockBackend > &other)
 Copy constructor of PGenericClock. More...
 
void setMode (PClockMode::PClockMode mode)
 Set the mode of the PGenericClock (NO_MOCK, MOCK or MOCK_RECORD) More...
 
virtual ~PGenericClock ()
 Destructor of PGenericClock. More...
 

Protected Member Functions

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

Private Member Functions

void initialisationPGenericClock ()
 Initialisation function of the class PGenericClock. More...
 

Private Attributes

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

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.

◆ 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  {
25  copyPGenericClock(other);
26 }
void copyPGenericClock(const PGenericClock< _TBackend, _TMockBackend > &other)
Copy function of PGenericClock.

◆ ~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  {
81  p_mode = other.p_mode;
82 }
PClockMode::PClockMode p_mode
Mode of the Clock (no mock, mock, mock_record)
Definition: PGenericClock.h:35

References PGenericClock< _TBackend, _TMockBackend >::p_mode.

◆ getMode()

template<typename _TBackend , typename _TMockBackend >
PClockMode::PClockMode PGenericClock< _TBackend, _TMockBackend >::getMode

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 }

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

◆ 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{
70  time_t currentTime = p_clockBackend.now();
71  p_mockBackend.setCurrentTime(currentTime);
72  return currentTime;
73  }
74 }
_TBackend p_clockBackend
Instance of the clock backend (necessary for some clock backends)
Definition: PGenericClock.h:37
_TMockBackend p_mockBackend
Instance of the clock backend (necessary for some clock backends)
Definition: PGenericClock.h:39

References PClockMode::MOCK, and PClockMode::NO_MOCK.

◆ 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  {
40  copyPGenericClock(other);
41  return *this;
42 }

◆ 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 }

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.

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

◆ 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 PGenericClock< _TBackend, _TMockBackend >::copyPGenericClock().


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