Lumiera  0.pre.03
»edit your freedom«
DiagnosticContext< VAL > Class Template Reference

#include "lib/diagnostic-context.hpp"

Description

template<typename VAL>
class lib::DiagnosticContext< VAL >

Diagnostic data frame to collect specific information concerning a scope.

To be placed explicitly as an automatic (stack) variable. Provides a controlled environment for hooking up diagnostic code. Within each thread, a stack of such information frames concerning nested scopes is maintained automatically. It can be accessed via static API.

Warning
relies on thread-local access; never use this within global data structures.

Definition at line 60 of file diagnostic-context.hpp.

Public Member Functions

 DiagnosticContext (VAL const &value_to_log=VAL())
 
 operator VAL const & ()
 

Static Public Member Functions

static DiagnosticContextaccess ()
 accessing the innermost diagnostic context created
 
static ValSequence extractStack ()
 snapshot of the current stack of diagnostic frames More...
 

Private Types

using ValSequence = std::vector< VAL >
 

Static Private Member Functions

static DiagnosticContext *& current ()
 embedded thread local pointer to the innermost context encountered
 

Private Attributes

DiagnosticContext *const prev_
 
const VAL value_
 

Additional Inherited Members

- Private Member Functions inherited from NonCopyable
 NonCopyable (NonCopyable const &)=delete
 
NonCopyableoperator= (NonCopyable const &)=delete
 

Member Function Documentation

◆ extractStack()

static ValSequence extractStack ( )
inlinestatic

snapshot of the current stack of diagnostic frames

Returns
vector with all the payload values currently on the thread-local diagnostic stack. Might be empty. Values start with frame next to the current scope and end with outermost.
Warning
can be inefficient on very large stacks
Todo:
benchmark and improve the data structure used for the snapshot. Vector is not an optimal choice here.

Definition at line 119 of file diagnostic-context.hpp.

References DiagnosticContext< VAL >::current().

Referenced by DiagnosticContext_test::verify_simpleAccess().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:
+ Inheritance diagram for DiagnosticContext< VAL >:
+ Collaboration diagram for DiagnosticContext< VAL >:

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