PhoenixSocket  1.0.0
Library which integrates socket unix use in Phoenix
Loading...
Searching...
No Matches
phoenix_mock_socket.cpp File Reference
#include <sstream>
#include "phoenix_mock_socket.h"
+ Include dependency graph for phoenix_mock_socket.cpp:

Go to the source code of this file.

Functions

bool phoenix_closeMockSocket (const PVecMockMessage &vecOutput, const std::string &outputFileName)
 Close a mock socket.
 
bool phoenix_createMockSocket (PVecMockMessage &vecInput, std::string &inputFileName, std::string &outputFileName, const std::string &address, size_t port)
 Create a mock socket.
 
bool phoenix_readMockSocket (PVecMockMessage &vecInput, const std::string &address, size_t port)
 Read a mock socket.
 

Function Documentation

◆ phoenix_closeMockSocket()

bool phoenix_closeMockSocket ( const PVecMockMessage & vecOutput,
const std::string & outputFileName )

Close a mock socket.

Parameters
vecOutput: vector of output messages to be saved
outputFileName: name of the output message file to be written
Returns
true on success, false otherwise

Definition at line 53 of file phoenix_mock_socket.cpp.

53 {
54 if(vecOutput.size() != 0lu){
55 return data_save(outputFileName, vecOutput);
56 }else{
57 return true;
58 }
59}

◆ phoenix_createMockSocket()

bool phoenix_createMockSocket ( PVecMockMessage & vecInput,
std::string & inputFileName,
std::string & outputFileName,
const std::string & address,
size_t port )

Create a mock socket.

Parameters
[out]vecInput: vector of input message to be read
[out]inputFileName: name of the input message file to be loaded
[out]outputFileName: name of the output message file to be written
address: host address
port: port to be used
Returns
true on success, false otherwise

Definition at line 18 of file phoenix_mock_socket.cpp.

18 {
19 std::stringstream strFileName;
20 strFileName << address << "_" << port << "_";
21 std::string baseFileName(strFileName.str());
22// inputFileName = baseFileName + "_recv.pmocksocket";
23// outputFileName = baseFileName + "_send.pmocksocket";
24
25 inputFileName = baseFileName + ".pmocksocket";
26 outputFileName = baseFileName + ".pmocksocket";
27
28 data_load(inputFileName, vecInput);
29 return true;
30}

◆ phoenix_readMockSocket()

bool phoenix_readMockSocket ( PVecMockMessage & vecInput,
const std::string & address,
size_t port )

Read a mock socket.

Parameters
[out]vecInput: vector of input message to be read
address: host address
port: port to be used
Returns
true on success, false otherwise

Definition at line 38 of file phoenix_mock_socket.cpp.

38 {
39 std::stringstream strFileName;
40 strFileName << address << "_" << port << "_";
41 std::string baseFileName(strFileName.str());
42
43 std::string inputFileName = baseFileName + ".pmocksocket";
44
45 return data_load(inputFileName, vecInput);
46}