bactria  0.0.1
The bactria library is a header-only C++14 library for profiling and tracing.
bactria::metrics::Phase Class Reference

The phase class. More...

#include <Phase.hpp>

Public Member Functions

 Phase ()=default
 The default constructor. More...
 
 Phase (std::string name)
 The non-entering constructor. More...
 
 Phase (std::string name, std::string source, std::uint32_t lineno, std::string caller)
 The entering constructor. More...
 
 Phase (const Phase &)=delete
 The copy constructor (deleted). More...
 
auto operator= (const Phase &) -> Phase &=delete
 The copy assignment operator (deleted). More...
 
 Phase (Phase &&other)
 The move constructor. More...
 
auto operator= (Phase &&rhs) -> Phase &
 The move assignment operator. More...
 
 ~Phase ()
 The destructor. More...
 
auto enter (std::string source, std::uint32_t lineno, std::string caller) -> void
 Enter the phase. More...
 
auto leave (std::string source, std::uint32_t lineno, std::string caller) -> void
 Leave the phase. More...
 

Detailed Description

The phase class.

Phases are used for structuring the program into logical segments. Sectors can be added to any phase in the program. Like Sectors, Phases have to be correctly nested.

Constructor & Destructor Documentation

◆ Phase() [1/5]

bactria::metrics::Phase::Phase ( )
default

The default constructor.

The default constructor will generate a phase with the name BACTRIA_GENERIC_PHASE. This phase will not be entered; this still needs to be done with a (correctly nested) pair of bactria_Enter() and bactria_Leave() or ~Phase().

See also
bactria_Enter, bactria_Leave, ~Phase

◆ Phase() [2/5]

bactria::metrics::Phase::Phase ( std::string  name)
inlineexplicit

The non-entering constructor.

The non-entering constructor will generate a phase with the name name. This phase will not be entered; this still needs to be done with a (correctly nested) pair of bactria_Enter() and bactria_Leave() or ~Phase().

Parameters
nameThe phase name as it should appear on the output file or visualizer.
See also
bactria_Enter, bactria_Leave, ~Phase

◆ Phase() [3/5]

bactria::metrics::Phase::Phase ( std::string  name,
std::string  source,
std::uint32_t  lineno,
std::string  caller 
)
inline

The entering constructor.

The entering constructor will generate a phase with the name name. This phase will be entered immediately. To leave it, the user can call bactria_Leave() or wait for ~Phase() to be triggered.

Parameters
nameThe phase name as it should appear on the output file or visualizer.
sourceThe source file this phase should be assigned to. This should be __FILE__.
linenoThe line number of the source file. This should be __LINE__.
callerThe surrounding function this phase is constructed in. This should be __func__.
See also
bactria_Enter, bactria_Leave, ~Phase()

◆ Phase() [4/5]

bactria::metrics::Phase::Phase ( const Phase )
delete

The copy constructor (deleted).

Phases are not intended to be copied. Thus, the copy constructor is deleted.

◆ Phase() [5/5]

bactria::metrics::Phase::Phase ( Phase &&  other)
inline

The move constructor.

Moves the other phase into this phase. Using other after the move results in undefined behaviour.

Parameters
otherThe phase to be moved.

◆ ~Phase()

bactria::metrics::Phase::~Phase ( )
inline

The destructor.

Destructs the phase. If the phase was entered and there was no preceeding call to bactria_Leave() or leave() the destructor will trigger this functionality before the contents of this are deleted.

See also
Phase, bactria_Enter, bactria_Leave, enter, leave

Member Function Documentation

◆ enter()

auto bactria::metrics::Phase::enter ( std::string  source,
std::uint32_t  lineno,
std::string  caller 
) -> void
inline

Enter the phase.

Enters the phase. It is allowed to enter a phase multiple times (for example in multiple code locations) as long as there is an equal amount of correctly nested calls to leave(), bactria_Leave() or ~Phase().

Parameters
sourceThe source file where the phase is entered. This should be __FILE__.
linenoThe source line where the phase is entered. This should be __LINE__.
callerThe function where the phase is entered. This should be __func__.
See also
bactria_Enter, bactria_Leave, leave, ~Phase

◆ leave()

auto bactria::metrics::Phase::leave ( std::string  source,
std::uint32_t  lineno,
std::string  caller 
) -> void
inline

Leave the phase.

Leaves the phase. It is allowed to leave a phase multiple times (for example in multiple code locations) as long as there is an equal amount of correctly nested calls to enter(), bactria_Enter() or Phase().

Parameters
sourceThe source file where the phase is left. This should be __FILE__.
linenoThe source line where the phase is left. This should be __LINE__.
callerThe function where the phase is left. This should be __func__.
See also
bactria_Enter, enter, bactria_Leave, Phase()

◆ operator=() [1/2]

auto bactria::metrics::Phase::operator= ( const Phase ) -> Phase &=delete
delete

The copy assignment operator (deleted).

Phases are not intended to be copied. Thus, the copy assignment operator is deleted.

◆ operator=() [2/2]

auto bactria::metrics::Phase::operator= ( Phase &&  rhs) -> Phase&
inline

The move assignment operator.

Moves the rhs phase into this phase. Using rhs after the move results in undefined behaviour.

Parameters
rhsThe phase to be moved.

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