PhoenixClock  2.2.0
Library wrapping the usage of system's clock, allowing to use clock mock-ups
Loading...
Searching...
No Matches
PClockMockFile.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 __PCLOCKMOCKFILE_H__
8#define __PCLOCKMOCKFILE_H__
9
10#include "PClockMock.h"
11#include "ellapsedTime.h"
12
15 public:
17 virtual ~PClockMockFile();
18
19 //clock API
20 time_t now();
21 void sleep(EllapsedTime ellapsedTime) const;
22
23 //mock API
24 void setCurrentTime(time_t currentTime);
25 void setMockPrefix(const std::string & mockPrefix);
26 void close();
27 private:
29
31 PGenericFileMock<time_t> p_mock;
32};
33
34bool phoenix_createMockBackend(PClockMockFile & mock, const std::string & prefix = "");
35bool phoenix_createClockMock(const std::string & prefix, size_t nbTime, time_t firstTime = 0l, time_t timeIncrement = 1l);
36
38
43template<class _TClockMock>
44void phoenix_fillClockMock(_TClockMock & mock, size_t nbTime, time_t firstTime, time_t timeIncrement){
45 time_t currentTime(firstTime);
46 for(size_t i(0lu); i < nbTime; ++i){
47 mock.setCurrentTime(currentTime);
48 currentTime += timeIncrement;
49 }
50
51}
52
53#endif
54
bool phoenix_createClockMock(const std::string &prefix, size_t nbTime, time_t firstTime=0l, time_t timeIncrement=1l)
Create a clock mock.
bool phoenix_createMockBackend(PClockMockFile &mock, const std::string &prefix="")
Create a mock backend for clock.
void phoenix_fillClockMock(_TClockMock &mock, size_t nbTime, time_t firstTime, time_t timeIncrement)
Fill the given clock mock.
Mock of a clock.
virtual ~PClockMockFile()
Destructor of PClockMockFile.
PClockMockFile()
Default constructor of PClockMockFile.
void setCurrentTime(time_t currentTime)
Set the current time to be recorded.
void close()
Close the PClockMockFile.
PGenericFileMock< time_t > p_mock
Mock handler.
void initialisationPClockMockFile()
Initialisation function of the class PClockMockFile.
void setMockPrefix(const std::string &mockPrefix)
Set the mock directory.
time_t now()
Get the mocked current time.
void sleep(EllapsedTime ellapsedTime) const
Sleep for the given ellapsed time.
time_t EllapsedTime