DGtal  1.4.beta
Trace.h
1 
17 #pragma once
30 #if defined(Trace_RECURSES)
31 #error Recursive header files inclusion detected in Trace.h
32 #else // defined(Trace_RECURSES)
34 #define Trace_RECURSES
35 
36 #if !defined Trace_h
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)
Virtual Class to implement trace writers.
Definition: TraceWriter.h:58
implementation of basic methods to trace out messages with indentation levels.
Definition: Trace.h:74
std::stack< Clock * > myClockStack
A stack to store the block clocks.
Definition: Trace.h:189
Trace(TraceWriter &writer)
Trace & operator=(const Trace &other)
std::ostream & error()
void selfDisplay(std::ostream &out) const
void beginBlock(const std::string &keyword="")
int myProgressBarCurrent
Progress bar current position.
Definition: Trace.h:192
Trace(const Trace &other)
std::string myCurrentPrefix
The indentation prefix string.
Definition: Trace.h:180
unsigned int myCurrentLevel
The indentation level.
Definition: Trace.h:178
std::stack< std::string > myKeywordStack
A stack to store the block keywords.
Definition: Trace.h:183
std::ostream & emphase()
bool isValid() const
bool myStyle
True if the style has changed.
Definition: Trace.h:198
unsigned int myProgressBarRotation
Progress bar rotation position.
Definition: Trace.h:195
std::ostream & info()
void progressBar(const double currentValue, const double maximalValue)
std::ostream & warning()
TraceWriter & myWriter
A reference to the output writer.
Definition: Trace.h:186
double endBlock()
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)