| Line | Branch | Exec | Source |
|---|---|---|---|
| 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 | ||
| 10 | ///Constructor of PDebugAssistant | ||
| 11 | 4 | PDebugAssistant::PDebugAssistant(){ | |
| 12 | |||
| 13 | 4 | } | |
| 14 | |||
| 15 | ///Destructor of PDebugAssistant | ||
| 16 | 4 | PDebugAssistant::~PDebugAssistant(){ | |
| 17 | 4 | clearTxt(); | |
| 18 | 4 | } | |
| 19 | |||
| 20 | ///Clear the file stream Map by closing all the files | ||
| 21 | 7 | void PDebugAssistant::clearTxt(){ | |
| 22 |
2/2✓ Branch 0 (3→4) taken 5 times.
✓ Branch 1 (3→5) taken 2 times.
|
7 | if(p_mapFileStreamTxt.size() == 0lu) return; |
| 23 |
2/2✓ Branch 0 (14→6) taken 4 times.
✓ Branch 1 (14→15) taken 2 times.
|
6 | for(PMapOfstream::iterator it(p_mapFileStreamTxt.begin()); it != p_mapFileStreamTxt.end(); ++it){ |
| 24 |
1/1✓ Branch 0 (7→8) taken 4 times.
|
4 | it->second->close(); |
| 25 |
1/2✓ Branch 0 (9→10) taken 4 times.
✗ Branch 1 (9→11) not taken.
|
4 | delete it->second; |
| 26 | } | ||
| 27 | 2 | p_mapFileStreamTxt.clear(); | |
| 28 | } | ||
| 29 | |||
| 30 | ///Clear the file stream Map by closing all the binary files | ||
| 31 | 1 | void PDebugAssistant::clearBin(){ | |
| 32 |
1/2✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→5) taken 1 times.
|
1 | if(p_mapBinStream.size() == 0lu) return; |
| 33 |
2/2✓ Branch 0 (14→6) taken 2 times.
✓ Branch 1 (14→15) taken 1 times.
|
3 | for(PMapBinstream::iterator it(p_mapBinStream.begin()); it != p_mapBinStream.end(); ++it){ |
| 34 |
1/1✓ Branch 0 (7→8) taken 2 times.
|
2 | it->second->close(); |
| 35 |
1/2✓ Branch 0 (9→10) taken 2 times.
✗ Branch 1 (9→11) not taken.
|
2 | delete it->second; |
| 36 | } | ||
| 37 | 1 | p_mapBinStream.clear(); | |
| 38 | } | ||
| 39 | |||
| 40 | ///Returns a file stream for the given file name | ||
| 41 | /** @param fileName : file name we want to write in | ||
| 42 | * @return corresponding file stream | ||
| 43 | */ | ||
| 44 | 600 | std::ofstream & PDebugAssistant::getTxtFile(const PPath & fileName){ | |
| 45 |
6/6✓ Branch 0 (2→3) taken 600 times.
✓ Branch 2 (3→4) taken 200 times.
✓ Branch 3 (3→11) taken 400 times.
✓ Branch 4 (4→5) taken 200 times.
✓ Branch 6 (5→6) taken 200 times.
✓ Branch 8 (6→7) taken 200 times.
|
600 | if(fileName == ""){return getTxtFile(PPath("default.txt"));} |
| 46 | |||
| 47 |
1/1✓ Branch 0 (11→12) taken 400 times.
|
400 | PMapOfstream::iterator it(p_mapFileStreamTxt.find(fileName)); |
| 48 | |||
| 49 |
2/2✓ Branch 0 (14→15) taken 396 times.
✓ Branch 1 (14→17) taken 4 times.
|
400 | if(it != p_mapFileStreamTxt.end()){ |
| 50 | 396 | return *(it->second); | |
| 51 | }else{ | ||
| 52 |
3/6✓ Branch 0 (17→18) taken 4 times.
✓ Branch 2 (18→19) taken 4 times.
✗ Branch 4 (19→20) not taken.
✓ Branch 5 (19→21) taken 4 times.
✗ Branch 6 (32→33) not taken.
✗ Branch 7 (32→34) not taken.
|
4 | std::ofstream * ptFs = new std::ofstream; |
| 53 |
1/1✓ Branch 0 (21→22) taken 4 times.
|
4 | ptFs->open(fileName); |
| 54 |
1/1✓ Branch 0 (22→23) taken 4 times.
|
4 | p_mapFileStreamTxt[fileName] = ptFs; |
| 55 | 4 | return *ptFs; | |
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | ///Returns a file stream for the given file name | ||
| 60 | /** @param fileName : file name we want to write in | ||
| 61 | * @return corresponding file stream | ||
| 62 | */ | ||
| 63 | 300 | PStream & PDebugAssistant::getBinFile(const PPath & fileName){ | |
| 64 |
6/6✓ Branch 0 (2→3) taken 300 times.
✓ Branch 2 (3→4) taken 100 times.
✓ Branch 3 (3→11) taken 200 times.
✓ Branch 4 (4→5) taken 100 times.
✓ Branch 6 (5→6) taken 100 times.
✓ Branch 8 (6→7) taken 100 times.
|
300 | if(fileName == ""){return getBinFile(PPath("default.bin"));} |
| 65 | |||
| 66 |
1/1✓ Branch 0 (11→12) taken 200 times.
|
200 | PMapBinstream::iterator it(p_mapBinStream.find(fileName)); |
| 67 | |||
| 68 |
2/2✓ Branch 0 (14→15) taken 198 times.
✓ Branch 1 (14→17) taken 2 times.
|
200 | if(it != p_mapBinStream.end()){ |
| 69 | 198 | return *(it->second); | |
| 70 | }else{ | ||
| 71 |
3/6✓ Branch 0 (17→18) taken 2 times.
✓ Branch 2 (18→19) taken 2 times.
✗ Branch 4 (19→20) not taken.
✓ Branch 5 (19→21) taken 2 times.
✗ Branch 6 (34→35) not taken.
✗ Branch 7 (34→36) not taken.
|
2 | PStream * ptFs = new PStream; |
| 72 |
2/2✓ Branch 0 (21→22) taken 2 times.
✓ Branch 2 (22→23) taken 2 times.
|
2 | ptFs->open(fileName, "w"); |
| 73 |
1/1✓ Branch 0 (24→25) taken 2 times.
|
2 | p_mapBinStream[fileName] = ptFs; |
| 74 | 2 | return *ptFs; | |
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 78 | #endif | ||
| 79 | |||
| 80 |