DGtal  1.1.0
Trace.h
1 
17 #pragma once
18 
30 #if defined(Trace_RECURSES)
31 #error Recursive header files inclusion detected in Trace.h
32 #else // defined(Trace_RECURSES)
33 
34 #define Trace_RECURSES
35 
36 #if !defined Trace_h
37 
38 #define Trace_h
39 
41 // Inclusions
42 #include <iostream>
43 #include <ostream>
44 #include <string>
45 #include <stack>
46 
47 #include "DGtal/base/Config.h"
48 #include "DGtal/base/Clock.h"
49 #include "DGtal/base/TraceWriter.h"
50 #include "DGtal/base/TraceWriterTerm.h"
52 
53 
54 namespace DGtal
55 {
56 
58  // class Trace
73  class Trace
74  {
75  // ----------------------- Standard services ------------------------------
76  public:
77 
79 #define TRACE_PATTERN " "
80 #define PROGRESSBARWIDTH 60
81 
82 
89  Trace(TraceWriter & writer);
90 
91 
95  ~Trace();
96 
101  void reset();
102 
103 
104 
110  void beginBlock(const std::string &keyword = "");
111 
117  double endBlock();
118 
123  std::ostream & info();
124 
130  std::ostream & warning();
131 
132 
138  std::ostream & error();
139 
140 
146  std::ostream & emphase();
147 
154  void progressBar(const double currentValue,
155  const double maximalValue);
156 
157 
158  // ----------------------- Interface --------------------------------------
159  public:
160 
165  void selfDisplay( std::ostream & out ) const;
166 
171  bool isValid() const;
172 
173  // ------------------------- Protected Datas ------------------------------
174  private:
175  // ------------------------- Private Datas --------------------------------
176  private:
178  unsigned int myCurrentLevel;
180  std::string myCurrentPrefix;
181 
183  std::stack<std::string> myKeywordStack;
184 
187 
189  std::stack<Clock*> myClockStack;
190 
193 
195  unsigned int myProgressBarRotation;
196 
198  bool myStyle;
199 
200  // ------------------------- Hidden services ------------------------------
201  protected:
202 
203  private:
204 
210  Trace( const Trace & other );
211 
218  Trace & operator=( const Trace & other );
219 
220 
221 
222 
223  // ------------------------- Internals ------------------------------------
224  private:
225 
226  }; // end of class Trace
227 
228 
235  std::ostream&
236  operator<<( std::ostream & out, const Trace & object );
237 
238 
239 } // namespace DGtal
240 
241 #include "DGtal/base/Assert.h"
242 
244 // Includes inline functions
245 #include "DGtal/base/Trace.ih"
246 
247 // //
249 
250 #endif // !defined Trace_h
251 
252 #undef Trace_RECURSES
253 #endif // else defined(Trace_RECURSES)
DGtal::Trace::isValid
bool isValid() const
DGtal::Trace::Trace
Trace(const Trace &other)
DGtal::Trace::endBlock
double endBlock()
DGtal::Trace::myWriter
TraceWriter & myWriter
A reference to the output writer.
Definition: Trace.h:186
DGtal::Trace::myProgressBarCurrent
int myProgressBarCurrent
Progress bar current position.
Definition: Trace.h:192
DGtal::Trace::error
std::ostream & error()
DGtal::Trace::emphase
std::ostream & emphase()
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::Trace
Trace(TraceWriter &writer)
DGtal::Trace
implementation of basic methods to trace out messages with indentation levels.
Definition: Trace.h:74
DGtal::Trace::operator=
Trace & operator=(const Trace &other)
DGtal::Trace::myClockStack
std::stack< Clock * > myClockStack
A stack to store the block clocks.
Definition: Trace.h:189
DGtal::Trace::info
std::ostream & info()
DGtal::Trace::progressBar
void progressBar(const double currentValue, const double maximalValue)
DGtal::Trace::myProgressBarRotation
unsigned int myProgressBarRotation
Progress bar rotation position.
Definition: Trace.h:195
DGtal::Trace::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::Trace::myCurrentPrefix
std::string myCurrentPrefix
The indentation prefix string.
Definition: Trace.h:180
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::Trace::reset
void reset()
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::Trace::myStyle
bool myStyle
True if the style has changed.
Definition: Trace.h:198
DGtal::TraceWriter
Virtual Class to implement trace writers.
Definition: TraceWriter.h:58
DGtal::Trace::myCurrentLevel
unsigned int myCurrentLevel
The indentation level.
Definition: Trace.h:178
DGtal::Trace::~Trace
~Trace()
DGtal::Trace::warning
std::ostream & warning()
DGtal::Trace::myKeywordStack
std::stack< std::string > myKeywordStack
A stack to store the block keywords.
Definition: Trace.h:183