PhoenixZMQ  2.0.0
Library which integrates zeromq use in Phoenix
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< DataStreamMsgPVecMockMessage
 Vector of messages. More...
 

Functions

template<typename T >
bool phoenix_addMockMessage (PVecMockMessage &vecOutput, const T &data)
 Add Data in a sequence of mock messages. More...
 
bool phoenix_closeMockSocket (const PVecMockMessage &vecOutput, const std::string &outputFileName)
 Close a mock socket. More...
 
bool phoenix_createMockSocket (PVecMockMessage &vecInput, std::string &inputFileName, std::string &outputFileName, const std::string &address, size_t port)
 Create a mock socket. More...
 
bool phoenix_readMockSocket (PVecMockMessage &vecInput, const std::string &address, size_t port)
 Read a mock socket. More...
 

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 }
bool data_message_save(DataStreamIter &iter, T &data)
Save data in a message.
Definition: data_message.h:18
size_t data_size(T &data)
Get size of data.
Definition: data_size.h:17
std::vector< DataStreamType > DataStreamMsg
DataStreamType * DataStreamIter

References data_message_save(), and data_size().

+ Here is the call graph for this function:

◆ 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 }
bool data_save(FILE *iter, const T &data)
Save data in a message.
Definition: data_file.h:18

References data_save().

+ Here is the call graph for this function:

◆ 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 }
bool data_load(FILE *iter, T &data)
Load data from a message.
Definition: data_file.h:39

References data_load().

+ Here is the call graph for this function:

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

References data_load().

+ Here is the call graph for this function: