PhoenixSocket  1.0.0
Library which integrates socket unix use in Phoenix
Loading...
Searching...
No Matches
phoenix_mock_socket.h File Reference
#include <data_size.h>
#include <data_file.h>
#include <data_message.h>
+ Include dependency graph for phoenix_mock_socket.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef std::vector< DataStreamMsg > PVecMockMessage
 Vector of messages.
 

Functions

template<typename T>
bool phoenix_addMockMessage (PVecMockMessage &vecOutput, const T &data)
 Add Data in a sequence of mock messages.
 
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.
 

Typedef Documentation

◆ PVecMockMessage

typedef std::vector<DataStreamMsg > PVecMockMessage

Vector of messages.

Definition at line 15 of file phoenix_mock_socket.h.

Function Documentation

◆ phoenix_addMockMessage()

template<typename T>
bool phoenix_addMockMessage ( PVecMockMessage & vecOutput,
const T & data )

Add Data in a sequence of mock messages.

Parameters
[out]vecOutput: vector of messages (sequence of message)
data: data to be added into the message
Returns
true if the message has been added successfully to the vecOutput, false otherwise

Definition at line 23 of file phoenix_mock_socket.h.

23 {
24 DataStreamMsg vecData(data_size(data));
25 DataStreamIter iter = (DataStreamIter)vecData.data();
26 if(data_message_save(iter, data)){
27 vecOutput.push_back(vecData);
28 return true;
29 }
30 return false;
31}

◆ 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}