PhoenixClock
2.6.0
Library wrapping the usage of system's clock, allowing to use clock mock-ups
Toggle main menu visibility
Loading...
Searching...
No Matches
PGenericClock_impl.h
Go to the documentation of this file.
1
/***************************************
2
Auteur : Pierre Aubert
3
Mail : pierre.aubert@lapp.in2p3.fr
4
Licence : CeCILL-C
5
****************************************/
6
7
#ifndef __PGENERICCLOCK_H_IMPL__
8
#define __PGENERICCLOCK_H_IMPL__
9
10
11
12
#include "
PGenericClock.h
"
13
15
template
<
typename
_TBackend,
typename
_TMockBackend>
16
PGenericClock<_TBackend, _TMockBackend>::PGenericClock
(){
17
initialisationPGenericClock
();
18
}
19
21
23
template
<
typename
_TBackend,
typename
_TMockBackend>
24
PGenericClock<_TBackend, _TMockBackend>::PGenericClock
(
const
PGenericClock<_TBackend, _TMockBackend>
& other){
25
copyPGenericClock
(other);
26
}
27
29
template
<
typename
_TBackend,
typename
_TMockBackend>
30
PGenericClock<_TBackend, _TMockBackend>::~PGenericClock
(){
31
32
}
33
35
38
template
<
typename
_TBackend,
typename
_TMockBackend>
39
PGenericClock<_TBackend, _TMockBackend>
&
PGenericClock<_TBackend, _TMockBackend>::operator =
(
const
PGenericClock<_TBackend, _TMockBackend>
& other){
40
copyPGenericClock
(other);
41
return
*
this
;
42
}
43
45
47
template
<
typename
_TBackend,
typename
_TMockBackend>
48
void
PGenericClock<_TBackend, _TMockBackend>::setMode
(
PClockMode::PClockMode
mode){
49
p_mode
= mode;
50
}
51
53
55
template
<
typename
_TBackend,
typename
_TMockBackend>
56
PClockMode::PClockMode
PGenericClock<_TBackend, _TMockBackend>::getMode
()
const
{
57
return
p_mode
;
58
}
59
61
63
template
<
typename
_TBackend,
typename
_TMockBackend>
64
time_t
PGenericClock<_TBackend, _TMockBackend>::now
(){
65
if
(
p_mode
==
PClockMode::NO_MOCK
){
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
}
75
77
79
template
<
typename
_TBackend,
typename
_TMockBackend>
80
void
PGenericClock<_TBackend, _TMockBackend>::sleep
(
EllapsedTime
ellapsedTime)
const
{
81
if
(
p_mode
==
PClockMode::NO_MOCK
||
p_mode
==
PClockMode::MOCK_RECORD
){
82
p_clockBackend
.sleep(ellapsedTime);
83
}
else
if
(
p_mode
==
PClockMode::MOCK
){
84
p_mockBackend
.sleep(ellapsedTime);
85
}
86
}
87
89
91
template
<
typename
_TBackend,
typename
_TMockBackend>
92
void
PGenericClock<_TBackend, _TMockBackend>::setMockPrefix
(
const
std::string & mockPrefix){
93
p_mockBackend
.setMockPrefix(mockPrefix);
94
}
95
97
template
<
typename
_TBackend,
typename
_TMockBackend>
98
void
PGenericClock<_TBackend, _TMockBackend>::resetMockIndex
(){
99
if
(
p_mode
==
PClockMode::MOCK
){
100
p_mockBackend
.resetIndex();
101
}
102
}
103
105
107
template
<
typename
_TBackend,
typename
_TMockBackend>
108
void
PGenericClock<_TBackend, _TMockBackend>::copyPGenericClock
(
const
PGenericClock<_TBackend, _TMockBackend>
& other){
109
p_mode
= other.
p_mode
;
110
}
111
113
template
<
typename
_TBackend,
typename
_TMockBackend>
114
void
PGenericClock<_TBackend, _TMockBackend>::initialisationPGenericClock
(){
115
p_mode
=
PClockMode::NO_MOCK
;
116
}
117
118
119
120
121
122
#endif
123
124
125
PGenericClock.h
PGenericClock::copyPGenericClock
void copyPGenericClock(const PGenericClock< _TBackend, _TMockBackend > &other)
Copy function of PGenericClock.
Definition
PGenericClock_impl.h:108
PGenericClock::PGenericClock
PGenericClock()
Default constructor of PGenericClock.
Definition
PGenericClock_impl.h:16
PGenericClock::getMode
PClockMode::PClockMode getMode() const
Get the mode of the PGenericClock (NO_MOCK, MOCK or MOCK_RECORD).
Definition
PGenericClock_impl.h:56
PGenericClock::resetMockIndex
void resetMockIndex()
Reset the mock clock to initial state.
Definition
PGenericClock_impl.h:98
PGenericClock::setMode
void setMode(PClockMode::PClockMode mode)
Set the mode of the PGenericClock (NO_MOCK, MOCK or MOCK_RECORD).
Definition
PGenericClock_impl.h:48
PGenericClock::~PGenericClock
virtual ~PGenericClock()
Destructor of PGenericClock.
Definition
PGenericClock_impl.h:30
PGenericClock::operator=
PGenericClock & operator=(const PGenericClock< _TBackend, _TMockBackend > &other)
Definition of equal operator of PGenericClock.
Definition
PGenericClock_impl.h:39
PGenericClock::setMockPrefix
void setMockPrefix(const std::string &mockPrefix)
Set the mock prefix to load and save the mock with a custom file.
Definition
PGenericClock_impl.h:92
PGenericClock::now
time_t now()
Get the current time of the clock.
Definition
PGenericClock_impl.h:64
PGenericClock::initialisationPGenericClock
void initialisationPGenericClock()
Initialisation function of the class PGenericClock.
Definition
PGenericClock_impl.h:114
PGenericClock::p_clockBackend
_TBackend p_clockBackend
Instance of the clock backend (necessary for some clock backends).
Definition
PGenericClock.h:39
PGenericClock::p_mockBackend
_TMockBackend p_mockBackend
Instance of the clock backend (necessary for some clock backends).
Definition
PGenericClock.h:41
PGenericClock::p_mode
PClockMode::PClockMode p_mode
Mode of the Clock (no mock, mock, mock_record).
Definition
PGenericClock.h:37
PGenericClock::sleep
void sleep(EllapsedTime ellapsedTime) const
Sleep for a given ellapsed time.
Definition
PGenericClock_impl.h:80
EllapsedTime
time_t EllapsedTime
Definition
ellapsedTime.h:12
PClockMode::PClockMode
PClockMode
describe the mode of the Socket
Definition
PClockMode.h:12
PClockMode::MOCK_RECORD
@ MOCK_RECORD
Definition
PClockMode.h:15
PClockMode::NO_MOCK
@ NO_MOCK
Definition
PClockMode.h:13
PClockMode::MOCK
@ MOCK
Definition
PClockMode.h:14
src
PGenericClock_impl.h
Generated by
1.17.0