GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixClock/src/PGenericClock_impl.h
Date: 2025-03-14 12:18:05
Exec Total Coverage
Lines: 18 18 100.0%
Branches: 5 5 100.0%

Line Branch Exec Source
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
14 ///Default constructor of PGenericClock
15 template<typename _TBackend, typename _TMockBackend>
16
1/1
✓ Branch 2 taken 7 times.
10 PGenericClock<_TBackend, _TMockBackend>::PGenericClock(){
17 10 initialisationPGenericClock();
18 10 }
19
20 ///Copy constructor of PGenericClock
21 /** @param other : class to copy
22 */
23 template<typename _TBackend, typename _TMockBackend>
24 PGenericClock<_TBackend, _TMockBackend>::PGenericClock(const PGenericClock<_TBackend, _TMockBackend> & other){
25 copyPGenericClock(other);
26 }
27
28 ///Destructor of PGenericClock
29 template<typename _TBackend, typename _TMockBackend>
30 16 PGenericClock<_TBackend, _TMockBackend>::~PGenericClock(){
31
32 }
33
34 ///Definition of equal operator of PGenericClock
35 /** @param other : class to copy
36 * @return copied class
37 */
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
44 ///Set the mode of the PGenericClock (NO_MOCK, MOCK or MOCK_RECORD)
45 /** @param mode : mode of the PGenericClock
46 */
47 template<typename _TBackend, typename _TMockBackend>
48 22 void PGenericClock<_TBackend, _TMockBackend>::setMode(PClockMode::PClockMode mode){
49 22 p_mode = mode;
50 22 }
51
52 ///Get the mode of the PGenericClock (NO_MOCK, MOCK or MOCK_RECORD)
53 /** @return mode of the PGenericClock
54 */
55 template<typename _TBackend, typename _TMockBackend>
56 PClockMode::PClockMode PGenericClock<_TBackend, _TMockBackend>::getMode() const{
57 return p_mode;
58 }
59
60 ///Get the current time of the clock
61 /** @return current time of the clock (the unit is given by the used backend, second for clock, ns for system_clock, etc)
62 */
63 template<typename _TBackend, typename _TMockBackend>
64 24 time_t PGenericClock<_TBackend, _TMockBackend>::now(){
65
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 10 times.
24 if(p_mode == PClockMode::NO_MOCK){
66 4 return p_clockBackend.now();
67
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
20 }else if(p_mode == PClockMode::MOCK){
68 16 return p_mockBackend.now();
69 }else{
70 4 time_t currentTime = p_clockBackend.now();
71 4 p_mockBackend.setCurrentTime(currentTime);
72 4 return currentTime;
73 }
74 }
75
76 ///Copy function of PGenericClock
77 /** @param other : class to copy
78 */
79 template<typename _TBackend, typename _TMockBackend>
80 void PGenericClock<_TBackend, _TMockBackend>::copyPGenericClock(const PGenericClock<_TBackend, _TMockBackend> & other){
81 p_mode = other.p_mode;
82 }
83
84 ///Initialisation function of the class PGenericClock
85 template<typename _TBackend, typename _TMockBackend>
86 10 void PGenericClock<_TBackend, _TMockBackend>::initialisationPGenericClock(){
87 10 p_mode = PClockMode::NO_MOCK;
88 10 }
89
90
91
92
93
94 #endif
95
96
97
98