GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/debug/debug.cpp Lines: 11 11 100.0 %
Date: 2023-03-15 12:04:10 Branches: 5 12 41.7 %

Line Branch Exec Source
1
/*
2
 * Copyright 2010,
3
 * François Bleibel,
4
 * Olivier Stasse,
5
 *
6
 * CNRS/AIST
7
 *
8
 */
9
10
#include <dynamic-graph/debug.h>
11
12
#include <fstream>
13
#include <ios>
14
15
using namespace dynamicgraph;
16
17
#ifdef WIN32
18
const char *DebugTrace::DEBUG_FILENAME_DEFAULT =
19
    "c:/tmp/dynamic-graph-traces.txt";
20
#else  /*WIN32*/
21
const char *DebugTrace::DEBUG_FILENAME_DEFAULT =
22
    "/tmp/dynamic-graph-traces.txt";
23
#endif /*WIN32*/
24
25
#ifdef VP_DEBUG
26
#ifdef WIN32
27
std::ofstream dg_debugfile("C:/tmp/dynamic-graph-traces.txt",
28
                           std::ios::trunc &std::ios::out);
29
#else  /*WIN32*/
30
std::ofstream dg_debugfile("/tmp/dynamic-graph-traces.txt",
31
                           std::ios::trunc &std::ios::out);
32
#endif /*WIN32*/
33
#else
34
std::ofstream dg_debugfile;
35
class dgDebug_init {
36
 public:
37
18
  dgDebug_init() { dg_debugfile.setstate(std::ios::failbit); }
38
};
39
dgDebug_init dgDebug_initialisator;
40
41
#endif
42
43
namespace dynamicgraph {
44
DebugTrace dgDEBUGFLOW(dg_debugfile);
45
DebugTrace dgERRORFLOW(dg_debugfile);
46
}  // namespace dynamicgraph
47
48
1
void DebugTrace::openFile(const char *filename) {
49

1
  if (dg_debugfile.good() && dg_debugfile.is_open()) dg_debugfile.close();
50
1
  dg_debugfile.clear();
51
1
  dg_debugfile.open(filename, std::ios::trunc & std::ios::out);
52
1
}
53
54
1
void DebugTrace::closeFile(const char *) {
55

1
  if (dg_debugfile.good() && dg_debugfile.is_open()) {
56
1
    dg_debugfile.close();
57
  }
58
1
  dg_debugfile.setstate(std::ios::failbit);
59
1
}