PhoenixZMQ  2.0.0
Library which integrates zeromq use in Phoenix
phoenix_mock_socket.cpp
Go to the documentation of this file.
1 /***************************************
2  Auteur : Pierre Aubert
3  Mail : pierre.aubert@lapp.in2p3.fr
4  Licence : CeCILL-C
5 ****************************************/
6 
7 #include <sstream>
8 #include "phoenix_mock_socket.h"
9 
11 
18 bool phoenix_createMockSocket(PVecMockMessage & vecInput, std::string & inputFileName, std::string & outputFileName, const std::string & address, size_t port){
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 }
31 
33 
38 bool phoenix_readMockSocket(PVecMockMessage & vecInput, const std::string & address, size_t port){
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 }
47 
49 
53 bool phoenix_closeMockSocket(const PVecMockMessage & vecOutput, const std::string & outputFileName){
54  if(vecOutput.size() != 0lu){
55  return data_save(outputFileName, vecOutput);
56  }else{
57  return true;
58  }
59 }
60 
bool data_load(FILE *iter, T &data)
Load data from a message.
Definition: data_file.h:39
bool data_save(FILE *iter, const T &data)
Save data in a message.
Definition: data_file.h:18
bool phoenix_readMockSocket(PVecMockMessage &vecInput, const std::string &address, size_t port)
Read 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_closeMockSocket(const PVecMockMessage &vecOutput, const std::string &outputFileName)
Close a mock socket.
std::vector< DataStreamMsg > PVecMockMessage
Vector of messages.