MeVisLab Toolbox Reference
ml::TraceBuffer< INDEXTYPE > Class Template Reference

This class manages a list and a stack of pointers to permanent strings. More...

#include <mlTrace.h>

Public Member Functions

 TraceBuffer ()
 Initializing constructor. More...
 
void add (const char *const traceInString)
 Adds an element. More...
 
void remove ()
 Destructor. More...
 
INDEXTYPE getTraceStackTop () const
 Returns index into trace stack buffer. More...
 
INDEXTYPE getTraceListEnd () const
 Returns index into trace list buffer. More...
 
const char *const * getTraceStack () const
 Returns the pointer to the first element of the trace stack. More...
 
const char *const * getTraceList () const
 Returns the pointer to the first element of the trace list. More...
 

Detailed Description

template<typename INDEXTYPE>
class ml::TraceBuffer< INDEXTYPE >

This class manages a list and a stack of pointers to permanent strings.

The constructor initializes the buffers to empty pointers. It will be used by the Trace class called by ML_TRACE_IN macros on function entries to track the call stack and call list. Overflows especially of the list will occur and are included in class design; so the buffers have exactly of a size identical with index range of the stack pointer and the list pointer. Accepting overflows limits the stack size and the number of list entries; however, no checks for overflow etc. are necessary which permits maximum tracing performance.

Parameters
INDEXTYPEspecifies the data type and indirectly the size of the stack and the list. Normally it should be MLuint8 or MLuint16 which then will result in 256 or 65536 stack and list entries. Other types are supported. WARNING: Tracing is currently not thread-safe for performance reasons. This means that it only works properly to use ML_TRACE_IN macros from the main thread. When calling functions that use ML_TRACE_IN macros from a different thread, this will mix-up the trace stack and list and the resulting stack and list may miss individual tracing items. It would be possible to support per-thread tracing by using thread local storage (TLS) in the future, but this involves a performance penalty.

Definition at line 53 of file mlTrace.h.

Constructor & Destructor Documentation

◆ TraceBuffer()

template<typename INDEXTYPE >
ml::TraceBuffer< INDEXTYPE >::TraceBuffer ( )
inline

Initializing constructor.

It resets the stack and list buffer and also listEnd and stackTop indices.

Definition at line 59 of file mlTrace.h.

Member Function Documentation

◆ add()

template<typename INDEXTYPE >
void ml::TraceBuffer< INDEXTYPE >::add ( const char *const  traceInString)
inline

Adds an element.

It appends the passed string reference to the trace buffer and to the top of the trace stack. Then it increases trace index and stack pointer. traceInString may be NULL. If not NULL, it must point to any null-terminated permanent string. VERY TIME CRITICAL!

Definition at line 78 of file mlTrace.h.

Referenced by ml::Trace< INDEXTYPE >::Trace().

◆ getTraceList()

template<typename INDEXTYPE >
const char* const* ml::TraceBuffer< INDEXTYPE >::getTraceList ( ) const
inline

Returns the pointer to the first element of the trace list.

Definition at line 141 of file mlTrace.h.

◆ getTraceListEnd()

template<typename INDEXTYPE >
INDEXTYPE ml::TraceBuffer< INDEXTYPE >::getTraceListEnd ( ) const
inline

Returns index into trace list buffer.

It addresses the entry to be written on next append.

Definition at line 131 of file mlTrace.h.

◆ getTraceStack()

template<typename INDEXTYPE >
const char* const* ml::TraceBuffer< INDEXTYPE >::getTraceStack ( ) const
inline

Returns the pointer to the first element of the trace stack.

Definition at line 136 of file mlTrace.h.

◆ getTraceStackTop()

template<typename INDEXTYPE >
INDEXTYPE ml::TraceBuffer< INDEXTYPE >::getTraceStackTop ( ) const
inline

Returns index into trace stack buffer.

It addresses the entry to be written on next push.

Definition at line 125 of file mlTrace.h.

◆ remove()

template<typename INDEXTYPE >
void ml::TraceBuffer< INDEXTYPE >::remove ( )
inline

Destructor.

It decreases stack pointer and resets last stored string pointer to VERY TIME CRITICAL!

Definition at line 106 of file mlTrace.h.


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