PhoenixClock  2.2.0
Library wrapping the usage of system's clock, allowing to use clock mock-ups
Loading...
Searching...
No Matches
PClockMockFile.h File Reference
#include "PClockMock.h"
#include "ellapsedTime.h"
+ Include dependency graph for PClockMockFile.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  PClockMockFile
 Mock of a clock. More...
 

Functions

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.
 
template<class _TClockMock>
void phoenix_fillClockMock (_TClockMock &mock, size_t nbTime, time_t firstTime, time_t timeIncrement)
 Fill the given clock mock.
 

Function Documentation

◆ phoenix_createClockMock()

bool phoenix_createClockMock ( const std::string & prefix,
size_t nbTime,
time_t firstTime,
time_t timeIncrement )

Create a clock mock.

Parameters
prefix: prefix where to find the mock file
nbTime: number of time values in the mock
firstTime: value of the first time
timeIncrement: increment between two consecutive times
Returns
true on success, false otherwise

Definition at line 27 of file PClockMockFile.cpp.

27 {
28 if(nbTime < 1000lu){ //For small clock we use a vector and a file otherwise
29 PClockMock mock;
30 phoenix_createMockBackend(mock, prefix);
31 phoenix_fillClockMock(mock, nbTime, firstTime, timeIncrement);
32 mock.close();
33 }else{
34 PClockMockFile mock;
35 phoenix_createMockBackend(mock, prefix);
36 phoenix_fillClockMock(mock, nbTime, firstTime, timeIncrement);
37 mock.close();
38 }
39 return true;
40}
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.
void close()
Close the PClockMockFile.
Mock of a clock.
Definition PClockMock.h:14
void close()
Close the mock.

References PClockMock::close(), PClockMockFile::close(), phoenix_createMockBackend(), and phoenix_fillClockMock().

+ Here is the call graph for this function:

◆ phoenix_createMockBackend()

bool phoenix_createMockBackend ( PClockMockFile & mock,
const std::string & prefix )

Create a mock backend for clock.

Parameters
[out]mock: clock mock backend to be used
prefix: prefix of the mock file
Returns
true on success, false otherwise

Definition at line 15 of file PClockMockFile.cpp.

15 {
16 mock.setMockPrefix(prefix);
17 return true;
18}
void setMockPrefix(const std::string &mockPrefix)
Set the mock directory.

References PClockMockFile::setMockPrefix().

Referenced by phoenix_createClockMock().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phoenix_fillClockMock()

template<class _TClockMock>
void phoenix_fillClockMock ( _TClockMock & mock,
size_t nbTime,
time_t firstTime,
time_t timeIncrement )

Fill the given clock mock.

Parameters
[out]mock: clock mock to be filled
nbTime: number of time values in the mock
firstTime: value of the first time
timeIncrement: increment between two consecutive times

Definition at line 44 of file PClockMockFile.h.

44 {
45 time_t currentTime(firstTime);
46 for(size_t i(0lu); i < nbTime; ++i){
47 mock.setCurrentTime(currentTime);
48 currentTime += timeIncrement;
49 }
50
51}

Referenced by phoenix_createClockMock().

+ Here is the caller graph for this function: