a110313707a003f498cde0a4c762cc988539de48
[libi2ncommon] / src / tracefunc.hpp
1 /** @file
2  * @brief provides tracing funtionality.
3  *
4  * Provides a scope tracker 
5  *
6  * @copyright © Copyright 2008 by Intra2net AG
7  * @license commercial
8  * 
9  * info@intra2net.com
10  */
11
12 #ifndef __I2N_COMMON_TRACEFUNC_HPP__
13 #define __I2N_COMMON_TRACEFUNC_HPP__
14
15 #include <string>
16 #include "logfunc.hpp"
17 #include "source_track_basics.hpp"
18
19
20 namespace I2n
21 {
22 namespace Tracer
23 {
24
25
26 /**
27  * @brief scope tracker class.
28  *
29  * basically: emits a ENTER message on construction and a LEAVE message on destruction.
30  * And indent these messages acoording to the nesting depth.
31  */
32 class ScopeTracker
33 {
34    public:
35      ScopeTracker(const SourceLocation& loc);
36      ~ScopeTracker();
37
38    private:
39      ScopeTracker(const ScopeTracker& rhs);
40      ScopeTracker& operator = (const ScopeTracker& rhs);
41
42      SourceLocation Location;
43      int Depth;
44      int FuncDepth;
45
46      std::string Tag;
47 }; // eo ScopeTracker
48
49
50 /*
51 ** helper macros:
52 */
53
54 /**
55  * @brief constructs a scope tracker.
56  */
57 #define SCOPETRACKER() ::I2n::Tracer::ScopeTracker __scope_tracker(HERE)
58
59
60 } // eo namespace Tracer
61 } // eo namespace I2n
62
63 #endif