aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/trace/tracevisitor.h
blob: 1556adffc5dbbb95ad3407c51e37e7ef573e32bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

namespace vespalib {

class TraceNode;

/**
 * This class is an abstract visitor of {@link TraceNode}. See {@link TraceNode#accept(TraceVisitor)}.
 */
struct TraceVisitor {
    virtual ~TraceVisitor() { }
    /**
     * Visits a {@link TraceNode}. Called by {@link TraceNode#accept(TraceVisitor)}, before visiting its children.
     *
     * @param node the TraceNode being visited
     * @see TraceNode#accept(TraceVisitor)
     */
    virtual void visit(const TraceNode & node) = 0;

    /**
     * Enters a {@link TraceNode}. This method is called after {@link #visit(TraceNode)}, but before visiting its children.
     * Note that this method is NOT called if TraceNode has zero children. The default implementation of this method does nothing.
     *
     * @param node The TraceNode being entered
     * @see #leaving(TraceNode)
     */
    virtual void entering(const TraceNode & node) { (void) node; }

    /**
     * Leaves a {@link TraceNode}. This method is called after {@link #entering(TraceNode)}, and after visiting its
     * children. Note that this method is NOT called if TraceNode has zero children.
     * The default implementation of this method does nothing.
     *
     * @param node the TraceNode being left
     */
    virtual void leaving(const TraceNode & node) { (void) node; }
};

} // namespace vespalib