File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/config/TeX-MML-AM_CHTML/MathJax.js
DGtal 2.0.0
DGtal::Trace Class Reference

implementation of basic methods to trace out messages with indentation levels. More...

#include <DGtal/base/Trace.h>

Public Member Functions

 Trace (TraceWriter &writer)
 ~Trace ()
void reset ()
void beginBlock (const std::string &keyword="")
double endBlock ()
std::ostream & info ()
std::ostream & warning ()
std::ostream & error ()
std::ostream & emphase ()
void progressBar (const double currentValue, const double maximalValue)
void selfDisplay (std::ostream &out) const
bool isValid () const

Private Member Functions

 Trace (const Trace &other)
Traceoperator= (const Trace &other)

Private Attributes

unsigned int myCurrentLevel
 The indentation level.
std::string myCurrentPrefix
 The indentation prefix string.
std::stack< std::string > myKeywordStack
 A stack to store the block keywords.
TraceWritermyWriter
 A reference to the output writer.
std::stack< Clock * > myClockStack
 A stack to store the block clocks.
int myProgressBarCurrent
 Progress bar current position.
unsigned int myProgressBarRotation
 Progress bar rotation position.
bool myStyle
 True if the style has changed.

Detailed Description

implementation of basic methods to trace out messages with indentation levels.

Description of class 'Trace'

Aim:

Trace objects use a TraceWriter to switch between terminal and file outputs. Methods postfixed with "Debug" contain no code if the compilation flag DEBUG is not set.

For usage examples, see the testtrace.cpp file.

See also
testTrace.cpp

Definition at line 73 of file Trace.h.

Constructor & Destructor Documentation

◆ Trace() [1/2]

DGtal::Trace::Trace ( TraceWriter & writer)

Constructor.

Parameters
writerthe output writer that will receive the traces.

Referenced by operator=(), and Trace().

◆ ~Trace()

DGtal::Trace::~Trace ( )

Destructor.

◆ Trace() [2/2]

DGtal::Trace::Trace ( const Trace & other)
private

Copy constructor.

Parameters
otherthe object to clone. Forbidden by default.

References Trace().

Member Function Documentation

◆ beginBlock()

void DGtal::Trace::beginBlock ( const std::string & keyword = "")

Enter a new block and increase the indentation level

Parameters
keywordcontains a label to the new block
Examples
dec/exampleDECSurface.cpp.

Referenced by testFileStream().

◆ emphase()

std::ostream & DGtal::Trace::emphase ( )

Create a string with an indentation prefix for an emphased trace.

Returns
the cerr output stream with the prefix

Referenced by testFileStream().

◆ endBlock()

double DGtal::Trace::endBlock ( )

Leave a current block, decrease the indentation level and display the associate keyword

Returns
the ellapsed time in the block in milliseconds (Class Clock).
Examples
dec/exampleDECSurface.cpp.

Referenced by testFileStream().

◆ error()

std::ostream & DGtal::Trace::error ( )

Create a string with an indentation prefix for an error trace. the string is postfixed by the keyword "[ERR]"

Returns
the cerr output stream with the prefix

Referenced by testFileStream().

◆ info()

std::ostream & DGtal::Trace::info ( )

Create a string with an indentation prefix for a normal trace.

Returns
the cerr output stream with the prefix
Examples
dec/exampleDECSurface.cpp.

Referenced by testFileStream().

◆ isValid()

bool DGtal::Trace::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

◆ operator=()

Trace & DGtal::Trace::operator= ( const Trace & other)
private

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'. Forbidden by default.

References Trace().

◆ progressBar()

void DGtal::Trace::progressBar ( const double currentValue,
const double maximalValue )

Display a progress bar in the terminal.

Parameters
currentValuecurrent step of the progress bar
maximalValueexpected maximal value (must be >0)

◆ reset()

void DGtal::Trace::reset ( )

Reset all the variables of the Trace object (indentation level and keyword stack)

◆ selfDisplay()

void DGtal::Trace::selfDisplay ( std::ostream & out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

◆ warning()

std::ostream & DGtal::Trace::warning ( )

Create a string with an indentation prefix for a warning trace. the string is postfixed by the keyword "[WRNG]"

Returns
the cerr output stream with the prefix

Referenced by testFileStream().

Field Documentation

◆ myClockStack

std::stack<Clock*> DGtal::Trace::myClockStack
private

A stack to store the block clocks.

Definition at line 189 of file Trace.h.

◆ myCurrentLevel

unsigned int DGtal::Trace::myCurrentLevel
private

The indentation level.

Definition at line 178 of file Trace.h.

◆ myCurrentPrefix

std::string DGtal::Trace::myCurrentPrefix
private

The indentation prefix string.

Definition at line 180 of file Trace.h.

◆ myKeywordStack

std::stack<std::string> DGtal::Trace::myKeywordStack
private

A stack to store the block keywords.

Definition at line 183 of file Trace.h.

◆ myProgressBarCurrent

int DGtal::Trace::myProgressBarCurrent
private

Progress bar current position.

Definition at line 192 of file Trace.h.

◆ myProgressBarRotation

unsigned int DGtal::Trace::myProgressBarRotation
private

Progress bar rotation position.

Definition at line 195 of file Trace.h.

◆ myStyle

bool DGtal::Trace::myStyle
private

True if the style has changed.

Definition at line 198 of file Trace.h.

◆ myWriter

TraceWriter& DGtal::Trace::myWriter
private

A reference to the output writer.

Definition at line 186 of file Trace.h.


The documentation for this class was generated from the following file: