PhoenixDebug  1.0.0
Tool to ease debugging
Loading...
Searching...
No Matches
PDebugAssistant.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 "PDebugAssistant.h"
8
9#ifndef DISABLE_DEBUG_ASSISTANT
14
19
22 if(p_mapFileStreamTxt.size() == 0lu) return;
23 for(PMapOfstream::iterator it(p_mapFileStreamTxt.begin()); it != p_mapFileStreamTxt.end(); ++it){
24 it->second->close();
25 delete it->second;
26 }
27 p_mapFileStreamTxt.clear();
28}
29
32 if(p_mapBinStream.size() == 0lu) return;
33 for(PMapBinstream::iterator it(p_mapBinStream.begin()); it != p_mapBinStream.end(); ++it){
34 it->second->close();
35 delete it->second;
36 }
37 p_mapBinStream.clear();
38}
39
41
44std::ofstream & PDebugAssistant::getTxtFile(const PPath & fileName){
45 if(fileName == ""){return getTxtFile(PPath("default.txt"));}
46
47 PMapOfstream::iterator it(p_mapFileStreamTxt.find(fileName));
48
49 if(it != p_mapFileStreamTxt.end()){
50 return *(it->second);
51 }else{
52 std::ofstream * ptFs = new std::ofstream;
53 ptFs->open(fileName);
54 p_mapFileStreamTxt[fileName] = ptFs;
55 return *ptFs;
56 }
57}
58
60
63PStream & PDebugAssistant::getBinFile(const PPath & fileName){
64 if(fileName == ""){return getBinFile(PPath("default.bin"));}
65
66 PMapBinstream::iterator it(p_mapBinStream.find(fileName));
67
68 if(it != p_mapBinStream.end()){
69 return *(it->second);
70 }else{
71 PStream * ptFs = new PStream;
72 ptFs->open(fileName, "w");
73 p_mapBinStream[fileName] = ptFs;
74 return *ptFs;
75 }
76}
77
78#endif
79
PMapBinstream p_mapBinStream
Map of binary stream.
std::ofstream & getTxtFile(const PPath &fileName=PPath("default.txt"))
Returns a file stream for the given file name.
void clearBin()
Clear the file stream Map by closing all the binary files.
PDebugAssistant()
Constructor of PDebugAssistant.
PStream & getBinFile(const PPath &fileName=PPath("default.bin"))
Returns a file stream for the given file name.
void clearTxt()
Clear the file stream Map by closing all the files.
virtual ~PDebugAssistant()
Destructor of PDebugAssistant.
PMapOfstream p_mapFileStreamTxt
Map of text file streams.