Yaets
Loading...
Searching...
No Matches
TraceGuard Class Reference

Class to manage the trace of a single function execution. More...

#include <tracing.hpp>

Inheritance diagram for TraceGuard:

Public Member Functions

std::chrono::nanoseconds get_start_time () const
 Retrieve the start time of the trace.
 
 TraceGuard (TraceSession &session, const std::string &trace_name)
 Construct a new TraceGuard object.
 
 ~TraceGuard ()
 Destroy the TraceGuard object.
 

Protected Member Functions

std::string extract_trace_name (const std::string &function_signature)
 Extract the function name from the full function signature.
 

Detailed Description

Class to manage the trace of a single function execution.

A TraceGuard object is created at the start of a function and destroyed when the function exits, automatically registering the start and end times of the function execution to the associated TraceSession.

Constructor & Destructor Documentation

◆ TraceGuard()

TraceGuard ( TraceSession & session,
const std::string & trace_name )

Construct a new TraceGuard object.

This constructor captures the function name and the start time of the function.

Parameters
sessionThe TraceSession to register the trace event with.
trace_nameThe name of the function being traced.

◆ ~TraceGuard()

~TraceGuard ( )

Destroy the TraceGuard object.

The destructor automatically registers the end time of the function and submits the trace event to the TraceSession.

Member Function Documentation

◆ extract_trace_name()

std::string extract_trace_name ( const std::string & function_signature)
protected

Extract the function name from the full function signature.

This function processes the function signature to extract only the relevant function name without parameters.

Parameters
function_signatureThe full function signature.
Returns
The extracted function name.

◆ get_start_time()

std::chrono::nanoseconds get_start_time ( ) const

Retrieve the start time of the trace.

This getter provides read-only access to the start time recorded by the TraceGuard at the beginning of a traced function execution.

Returns
The start time of the function execution as a std::chrono::nanoseconds duration.

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