Poplar and PopLibs
|
DebugContext gathers the common external parameters of the context of an operation. More...
#include <DebugContext.hpp>
Public Member Functions | |
std::string | getPathName () const |
Gets the pathname of this object as the concatenation of the parent name received in the constructor via DebugInfo or DebugNameAndId and the name explicitly set for this object. | |
DebugContext gathers the common external parameters of the context of an operation.
As an extension to DebugNameAndId, DebugContext bundles a name and a DebugId as well as the file and line in the source code where it is invoked.
Note that to reflect the specific line where an invocation took place, the DebugContext object must be constructed in the same line of the invocation. For instance, if a function foo
wants to capture the DebugContext of its invocation, it should be called like this:
Rather than:
Although typically foo
would accept a default argument:
so that the DebugContext can be automatically captured:
The ultimate target of DebugContext is to be passed to the constructor of a DebugInfo object. The DebugContext carries the DebugId of the parent DebugInfo to keep a hierarchical relationship. A typical flow would be:
The initial DebugContext is (implicitly) created in foo
default argument and used to create the initial DebugInfo. Then foo2
is called:
foo2
captures the DebugContext that contains the parent DebugId:
In this way, low-level operations and resources can be related to the high-level operation that triggered them.