Public Member Functions | Private Member Functions | Private Attributes

DGtal::Trace Class Reference

#include <Trace.h>

Collaboration diagram for DGtal::Trace:
Collaboration graph
[legend]

Public Member Functions

 Trace (TraceWriter &writer)
 ~Trace ()
void reset ()
void beginBlock (const std::string &keyword="")
long endBlock ()
std::ostream & info () const
std::ostream & warning () const
std::ostream & error () const
std::ostream & emphase () const
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
std::string myCurrentPrefix
std::stack< std::string > myKeywordStack
TraceWritermyWriter
std::stack< Clock * > myClockStack

Detailed Description

Description of class 'Trace'

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

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
Todo:
Create a default constructor on TraceWriterTerm(std::cerr)

Constructor & Destructor Documentation

DGtal::Trace::Trace ( TraceWriter writer  ) 

Constructor.

Parameters:
writer the output writer that will receive the traces.
DGtal::Trace::~Trace (  ) 

Destructor.

DGtal::Trace::Trace ( const Trace other  )  [private]

Copy constructor.

Parameters:
other the object to clone. Forbidden by default.

Member Function Documentation

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

Enter a new block and increase the indentation level

Parameters:
keyword contains a label to the new block
Examples:
dgtalboard-1-points.cpp, dgtalboard-2-sets.cpp, dgtalboard-3-custom-classes.cpp, dgtalboard-3-custom-points.cpp, dgtalboard-4-colormaps.cpp, dgtalboard-5-greedy-dss.cpp, distancetransform2D.cpp, and DSS.cpp.

Referenced by builtinIteratorScan(), domainIteratorScan(), main(), testBadKeySizes(), testBasicBoolFunctions(), testCheckImageConcept(), testChessboard(), testComparison(), testDGtalBoard(), testDigitalSet(), testDigitalSetDomain(), testDigitalSetDraw(), testDigitalSetSelector(), testDigitalTopologyZ2(), testDistanceTransformation(), testDistanceTransformation3D(), testDistanceTransformationBorder(), testDomain(), testDraw(), testDuvalPP(), testDuvalPPMod(), testExpander(), testFileStream(), testFLF(), testFreemanChain(), testGetSetVal(), testGrayscaleColorMap(), testHashTree(), testImageContainerBenchmark(), testIndent(), testInteger(), testIntegerNorms(), testIOException(), testIterator(), testITKImage(), testIVViewer(), testIVViewerSimpleWdw(), testMagickReader(), testMetricAdjacency(), testModuloComputer(), testMorton(), testNorms(), testObject(), testObject3D(), testObjectBorder(), testOperators(), testPNMWriter(), testRawReader2D(), testReverseIterator(), testSimpleExpander(), testSimpleHyperRectDomain(), testSimpleImage(), testSimplePoint(), testSimplePoints2D(), testSimplePoints3D(), testSimpleVector(), testSpanIterators(), testSTLCompat(), testSuite(), testTypeValidity(), testVolReader(), and testVTKImageContainer().

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

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

Returns:
the cerr output stream with the prefix

Referenced by main(), testFileStream(), testIterator(), testReverseIterator(), testSimple(), testSTLCompat(), testUnitSquare(), and testUnitSquareCentroid().

long 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:
dgtalboard-1-points.cpp, dgtalboard-2-sets.cpp, dgtalboard-3-custom-classes.cpp, dgtalboard-3-custom-points.cpp, dgtalboard-4-colormaps.cpp, dgtalboard-5-greedy-dss.cpp, distancetransform2D.cpp, and DSS.cpp.

Referenced by builtinIteratorScan(), domainIteratorScan(), main(), testBadKeySizes(), testBasicBoolFunctions(), testCheckImageConcept(), testChessboard(), testComparison(), testDGtalBoard(), testDigitalSet(), testDigitalSetDomain(), testDigitalSetDraw(), testDigitalSetSelector(), testDigitalTopologyZ2(), testDistanceTransformation(), testDistanceTransformation3D(), testDistanceTransformationBorder(), testDomain(), testDraw(), testDuvalPP(), testDuvalPPMod(), testExpander(), testFileStream(), testFLF(), testGetSetVal(), testGrayscaleColorMap(), testHashTree(), testImageContainerBenchmark(), testIndent(), testInteger(), testIntegerNorms(), testIOException(), testIterator(), testITKImage(), testIVViewer(), testIVViewerSimpleWdw(), testMagickReader(), testMetricAdjacency(), testModuloComputer(), testMorton(), testNorms(), testObject(), testObject3D(), testObjectBorder(), testOperators(), testPNMWriter(), testRawReader2D(), testReverseIterator(), testSimpleBoard(), testSimpleExpander(), testSimpleHyperRectDomain(), testSimpleImage(), testSimplePoint(), testSimplePoints2D(), testSimplePoints3D(), testSimpleVector(), testSpanIterators(), testSTLCompat(), testSuite(), testTypeValidity(), testVolReader(), and testVTKImageContainer().

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

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(), testGetSetVal(), testIndent(), testSimple(), and testSuite().

std::ostream& DGtal::Trace::info (  )  const
bool DGtal::Trace::isValid (  )  const

Checks the validity/consistency of the object.

Returns:
'true' if the object is valid, 'false' otherwise.
Trace& DGtal::Trace::operator= ( const Trace other  )  [private]

Assignment.

Parameters:
other the object to copy.
Returns:
a reference on 'this'. Forbidden by default.
void DGtal::Trace::reset (  ) 

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

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

Writes/Displays the object on an output stream.

Parameters:
out the output stream where the object is written.
std::ostream& DGtal::Trace::warning (  )  const

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
Examples:
distancetransform2D.cpp.

Referenced by testChessboard(), testDistanceTransformation(), testDistanceTransformation3D(), testDistanceTransformationBorder(), testFileStream(), testGetSetVal(), testIndent(), testIterator(), testITKImage(), testMorton(), testSimple(), and testSuite().


Field Documentation

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

A stack to store the block clocks.

unsigned int DGtal::Trace::myCurrentLevel [private]

The indentation level.

std::string DGtal::Trace::myCurrentPrefix [private]

The indentation prefix string.

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

A stack to store the block keywords.

A reference to the output writer.


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