Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
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 51 of file diagnostic-context.hpp.

Static Public Member Functions

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

Public Member Functions

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

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

const VAL value_
 
DiagnosticContext *const prev_
 

Additional Inherited Members

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

Constructor & Destructor Documentation

◆ DiagnosticContext()

template<typename VAL >
DiagnosticContext ( VAL const &  value_to_log = VAL())
inline

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

References DiagnosticContext< VAL >::current().

+ Here is the call graph for this function:

◆ ~DiagnosticContext()

template<typename VAL >
~DiagnosticContext ( )
inline

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

References DiagnosticContext< VAL >::current(), and DiagnosticContext< VAL >::prev_.

+ Here is the call graph for this function:

Member Typedef Documentation

◆ ValSequence

template<typename VAL >
using ValSequence = std::vector<VAL>
private

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

Member Function Documentation

◆ current()

template<typename VAL >
static DiagnosticContext *& current ( )
inlinestaticprivate

embedded thread local pointer to the innermost context encountered

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

Referenced by DiagnosticContext< VAL >::DiagnosticContext(), DiagnosticContext< VAL >::~DiagnosticContext(), DiagnosticContext< VAL >::access(), and DiagnosticContext< VAL >::extractStack().

+ Here is the caller graph for this function:

◆ operator VAL const &()

template<typename VAL >
operator VAL const & ( )
inline

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

References DiagnosticContext< VAL >::value_.

◆ access()

template<typename VAL >
static DiagnosticContext & access ( )
inlinestatic

accessing the innermost diagnostic context created

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

References DiagnosticContext< VAL >::current().

+ Here is the call graph for this function:

◆ extractStack()

template<typename VAL >
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 110 of file diagnostic-context.hpp.

References DiagnosticContext< VAL >::current(), and DiagnosticContext< VAL >::prev_.

+ Here is the call graph for this function:

Member Data Documentation

◆ value_

template<typename VAL >
const VAL value_
private

◆ prev_

template<typename VAL >
DiagnosticContext* const prev_
private
+ Inheritance diagram for DiagnosticContext< VAL >:
+ Collaboration diagram for DiagnosticContext< VAL >:

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