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

Mock of a clock. More...

#include <PClockMockFile.h>

Public Member Functions

void close ()
 Close the PClockMockFile.
 
time_t now ()
 Get the mocked current time.
 
 PClockMockFile ()
 Default constructor of PClockMockFile.
 
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 ellapsedTime) const
 Sleep for the given ellapsed time.
 
virtual ~PClockMockFile ()
 Destructor of PClockMockFile.
 

Private Member Functions

void initialisationPClockMockFile ()
 Initialisation function of the class PClockMockFile.
 

Private Attributes

PGenericFileMock< time_t > p_mock
 Mock handler.
 

Detailed Description

Mock of a clock.

Definition at line 14 of file PClockMockFile.h.

Constructor & Destructor Documentation

◆ PClockMockFile()

PClockMockFile::PClockMockFile ( )

Default constructor of PClockMockFile.

Definition at line 43 of file PClockMockFile.cpp.

43 {
45}
void initialisationPClockMockFile()
Initialisation function of the class PClockMockFile.

References initialisationPClockMockFile().

+ Here is the call graph for this function:

◆ ~PClockMockFile()

PClockMockFile::~PClockMockFile ( )
virtual

Destructor of PClockMockFile.

Definition at line 48 of file PClockMockFile.cpp.

48 {
49 close();
50}
void close()
Close the PClockMockFile.

References close().

+ Here is the call graph for this function:

Member Function Documentation

◆ close()

void PClockMockFile::close ( )

Close the PClockMockFile.

Definition at line 88 of file PClockMockFile.cpp.

88 {
89 p_mock.close();
90}
PGenericFileMock< time_t > p_mock
Mock handler.

References p_mock.

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

+ Here is the caller graph for this function:

◆ initialisationPClockMockFile()

void PClockMockFile::initialisationPClockMockFile ( )
private

Initialisation function of the class PClockMockFile.

Definition at line 93 of file PClockMockFile.cpp.

93 {
94
95}

Referenced by PClockMockFile().

+ Here is the caller graph for this function:

◆ now()

time_t PClockMockFile::now ( )

Get the mocked current time.

Returns
mocked current time

Definition at line 55 of file PClockMockFile.cpp.

55 {
56 p_mock.setIsRecord(false);
57 time_t currentTime = 0lu;
58 p_mock.getCurrentValue(currentTime);
59 return currentTime;
60}

References p_mock.

◆ setCurrentTime()

void PClockMockFile::setCurrentTime ( time_t currentTime)

Set the current time to be recorded.

Parameters
currentTime: current time to be recorded

Definition at line 72 of file PClockMockFile.cpp.

72 {
73 p_mock.setIsRecord(true);
74 //Let's record the given time
75 p_mock.append(currentTime);
76}

References p_mock.

◆ setMockPrefix()

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

Set the mock directory.

Parameters
mockDirectory: mock directory

Definition at line 81 of file PClockMockFile.cpp.

81 {
82 std::stringstream socketFileName;
83 socketFileName << mockPrefix << "clock.pclockmock";
84 p_mock.setFileName(socketFileName.str());
85}

References p_mock.

Referenced by phoenix_createMockBackend().

+ Here is the caller graph for this function:

◆ sleep()

void PClockMockFile::sleep ( EllapsedTime ellapsedTime) const

Sleep for the given ellapsed time.

Parameters
ellapsedTime: time to sleep

Definition at line 65 of file PClockMockFile.cpp.

65 {
66 //No real sleep in mock
67}

Member Data Documentation

◆ p_mock

PGenericFileMock<time_t> PClockMockFile::p_mock
private

Mock handler.

Definition at line 31 of file PClockMockFile.h.

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


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