PhoenixClock  2.2.0
Library wrapping the usage of system's clock, allowing to use clock mock-ups
Loading...
Searching...
No Matches
PClockMock.cpp
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
8#include "PClockMock.h"
9
11
15bool phoenix_createMockBackend(PClockMock & mock, const std::string & prefix){
16 mock.setMockPrefix(prefix);
17 return true;
18}
19
24
29
31
34 p_mock.setIsRecord(false);
35 time_t currentTime = 0lu;
36 p_mock.getCurrentValue(currentTime);
37 return currentTime;
38}
39
41
43void PClockMock::sleep(EllapsedTime sleepTime) const{
44 //Do nothing for the mock
45}
46
48
50void PClockMock::setCurrentTime(time_t currentTime){
51 p_mock.setIsRecord(true);
52 //Let's record the given time
53 p_mock.append(currentTime);
54}
55
57
59void PClockMock::setMockPrefix(const std::string & mockPrefix){
60 std::stringstream socketFileName;
61 socketFileName << mockPrefix << "clock.pclockmock";
62 p_mock.setFileName(socketFileName.str());
63}
64
67 p_mock.resetIndex();
68}
69
72 p_mock.close();
73}
74
79
80
81
82
83
bool phoenix_createMockBackend(PClockMock &mock, const std::string &prefix)
Create a mock backend for clock.
Mock of a clock.
Definition PClockMock.h:14
void resetIndex()
Reset the mock index to the beginning.
void close()
Close the mock.
PClockMock()
Default constructor of PClockMock.
time_t now()
Get the mocked current time.
virtual ~PClockMock()
Destructor of PClockMock.
void setCurrentTime(time_t currentTime)
Set the current time to be recorded.
void initialisationPClockMock()
Initialisation function of the class PClockMock.
PGenericVecMock< time_t > p_mock
Mock handler.
Definition PClockMock.h:31
void setMockPrefix(const std::string &mockPrefix)
Set the mock directory.
void sleep(EllapsedTime sleepTime) const
Sleep for the given time.
time_t EllapsedTime