PhoenixClock  2.2.0
Library wrapping the usage of system's clock, allowing to use clock mock-ups
Loading...
Searching...
No Matches
PClockMock Class Reference

Mock of a clock. More...

#include <PClockMock.h>

Public Member Functions

void close ()
 Close the mock.
 
time_t now ()
 Get the mocked current time.
 
 PClockMock ()
 Default constructor of PClockMock.
 
void resetIndex ()
 Reset the mock index to the beginning.
 
void setCurrentTime (time_t currentTime)
 Set the current time to be recorded.
 
void setMockPrefix (const std::string &mockPrefix)
 Set the mock directory.
 
void sleep (EllapsedTime sleepTime) const
 Sleep for the given time.
 
virtual ~PClockMock ()
 Destructor of PClockMock.
 

Private Member Functions

void initialisationPClockMock ()
 Initialisation function of the class PClockMock.
 

Private Attributes

PGenericVecMock< time_t > p_mock
 Mock handler.
 

Detailed Description

Mock of a clock.

Definition at line 14 of file PClockMock.h.

Constructor & Destructor Documentation

◆ PClockMock()

PClockMock::PClockMock ( )

Default constructor of PClockMock.

Definition at line 21 of file PClockMock.cpp.

21 {
23}
void initialisationPClockMock()
Initialisation function of the class PClockMock.

References initialisationPClockMock().

+ Here is the call graph for this function:

◆ ~PClockMock()

PClockMock::~PClockMock ( )
virtual

Destructor of PClockMock.

Definition at line 26 of file PClockMock.cpp.

26 {
27 close();
28}
void close()
Close the mock.

References close().

+ Here is the call graph for this function:

Member Function Documentation

◆ close()

void PClockMock::close ( )

Close the mock.

Definition at line 71 of file PClockMock.cpp.

71 {
72 p_mock.close();
73}
PGenericVecMock< time_t > p_mock
Mock handler.
Definition PClockMock.h:31

References p_mock.

Referenced by phoenix_createClockMock(), and ~PClockMock().

+ Here is the caller graph for this function:

◆ initialisationPClockMock()

void PClockMock::initialisationPClockMock ( )
private

Initialisation function of the class PClockMock.

Definition at line 76 of file PClockMock.cpp.

76 {
77
78}

Referenced by PClockMock().

+ Here is the caller graph for this function:

◆ now()

time_t PClockMock::now ( )

Get the mocked current time.

Returns
mocked current time

Definition at line 33 of file PClockMock.cpp.

33 {
34 p_mock.setIsRecord(false);
35 time_t currentTime = 0lu;
36 p_mock.getCurrentValue(currentTime);
37 return currentTime;
38}

References p_mock.

◆ resetIndex()

void PClockMock::resetIndex ( )

Reset the mock index to the beginning.

Definition at line 66 of file PClockMock.cpp.

66 {
67 p_mock.resetIndex();
68}

References p_mock.

◆ setCurrentTime()

void PClockMock::setCurrentTime ( time_t currentTime)

Set the current time to be recorded.

Parameters
currentTime: current time to be recorded

Definition at line 50 of file PClockMock.cpp.

50 {
51 p_mock.setIsRecord(true);
52 //Let's record the given time
53 p_mock.append(currentTime);
54}

References p_mock.

◆ setMockPrefix()

void PClockMock::setMockPrefix ( const std::string & mockPrefix)

Set the mock directory.

Parameters
mockDirectory: mock directory

Definition at line 59 of file PClockMock.cpp.

59 {
60 std::stringstream socketFileName;
61 socketFileName << mockPrefix << "clock.pclockmock";
62 p_mock.setFileName(socketFileName.str());
63}

References p_mock.

Referenced by phoenix_createMockBackend().

+ Here is the caller graph for this function:

◆ sleep()

void PClockMock::sleep ( EllapsedTime sleepTime) const

Sleep for the given time.

Parameters
sleepTime: time to sleep

Definition at line 43 of file PClockMock.cpp.

43 {
44 //Do nothing for the mock
45}

Member Data Documentation

◆ p_mock

PGenericVecMock<time_t> PClockMock::p_mock
private

Mock handler.

Definition at line 31 of file PClockMock.h.

Referenced by close(), now(), resetIndex(), setCurrentTime(), and setMockPrefix().


The documentation for this class was generated from the following files: