Run shorten_stl_types (and a bit more) only if needed in scope tracker
[libi2ncommon] / src / tracefunc.hpp
CommitLineData
0e23f538
TJ
1/*
2The software in this package is distributed under the GNU General
3Public License version 2 (with a special exception described below).
4
5A copy of GNU General Public License (GPL) is included in this distribution,
6in the file COPYING.GPL.
7
8As a special exception, if other files instantiate templates or use macros
9or inline functions from this file, or you compile this file and link it
10with other works to produce a work based on this file, this file
11does not by itself cause the resulting work to be covered
12by the GNU General Public License.
13
14However the source code for this file must still be made available
15in accordance with section (3) of the GNU General Public License.
16
17This exception does not invalidate any other reasons why a work based
18on this file might be covered by the GNU General Public License.
19*/
b6fb82a2
RP
20/** @file
21 * @brief provides tracing funtionality.
22 *
23 * Provides a scope tracker
24 *
25 * @copyright © Copyright 2008 by Intra2net AG
0e23f538 26*/
b6fb82a2
RP
27#ifndef __I2N_COMMON_TRACEFUNC_HPP__
28#define __I2N_COMMON_TRACEFUNC_HPP__
29
30#include <string>
31#include "logfunc.hpp"
32#include "source_track_basics.hpp"
33
34
35namespace I2n
36{
37namespace Tracer
38{
39
f4fcef65 40class PerThreadContainer;
b6fb82a2
RP
41
42/**
43 * @brief scope tracker class.
44 *
45 * basically: emits a ENTER message on construction and a LEAVE message on destruction.
46 * And indent these messages acoording to the nesting depth.
47 */
48class ScopeTracker
49{
50 public:
51 ScopeTracker(const SourceLocation& loc);
52 ~ScopeTracker();
53
54 private:
55 ScopeTracker(const ScopeTracker& rhs);
56 ScopeTracker& operator = (const ScopeTracker& rhs);
57
58 SourceLocation Location;
59 int Depth;
60 int FuncDepth;
61
fdd09ae0
CH
62 std::string Tag; // might be empty
63 std::string &get_tag(); // returns Tag, creates it first if necessary
f4fcef65
TJ
64
65 PerThreadContainer *PerThread;
b6fb82a2
RP
66}; // eo ScopeTracker
67
68
69/*
70** helper macros:
71*/
72
73/**
74 * @brief constructs a scope tracker.
75 */
76#define SCOPETRACKER() ::I2n::Tracer::ScopeTracker __scope_tracker(HERE)
77
78
79} // eo namespace Tracer
80} // eo namespace I2n
81
82#endif