Commit | Line | Data |
---|---|---|
0e23f538 TJ |
1 | /* |
2 | The software in this package is distributed under the GNU General | |
3 | Public License version 2 (with a special exception described below). | |
4 | ||
5 | A copy of GNU General Public License (GPL) is included in this distribution, | |
6 | in the file COPYING.GPL. | |
7 | ||
8 | As a special exception, if other files instantiate templates or use macros | |
9 | or inline functions from this file, or you compile this file and link it | |
10 | with other works to produce a work based on this file, this file | |
11 | does not by itself cause the resulting work to be covered | |
12 | by the GNU General Public License. | |
13 | ||
14 | However the source code for this file must still be made available | |
15 | in accordance with section (3) of the GNU General Public License. | |
16 | ||
17 | This exception does not invalidate any other reasons why a work based | |
18 | on 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 | ||
35 | namespace I2n | |
36 | { | |
37 | namespace Tracer | |
38 | { | |
39 | ||
f4fcef65 | 40 | class 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. | |
096e680f CH |
47 | * |
48 | * If something goes wrong nothing is thrown from constructor/destructor. Will try to | |
49 | * log only that some problem occurred. | |
b6fb82a2 RP |
50 | */ |
51 | class ScopeTracker | |
52 | { | |
53 | public: | |
096e680f CH |
54 | ScopeTracker(const SourceLocation& loc) throw (); |
55 | ~ScopeTracker() throw (); | |
b6fb82a2 RP |
56 | |
57 | private: | |
58 | ScopeTracker(const ScopeTracker& rhs); | |
59 | ScopeTracker& operator = (const ScopeTracker& rhs); | |
60 | ||
61 | SourceLocation Location; | |
62 | int Depth; | |
63 | int FuncDepth; | |
64 | ||
fdd09ae0 CH |
65 | std::string Tag; // might be empty |
66 | std::string &get_tag(); // returns Tag, creates it first if necessary | |
f4fcef65 TJ |
67 | |
68 | PerThreadContainer *PerThread; | |
b6fb82a2 RP |
69 | }; // eo ScopeTracker |
70 | ||
71 | ||
72 | /* | |
73 | ** helper macros: | |
74 | */ | |
75 | ||
76 | /** | |
77 | * @brief constructs a scope tracker. | |
78 | */ | |
79 | #define SCOPETRACKER() ::I2n::Tracer::ScopeTracker __scope_tracker(HERE) | |
80 | ||
81 | ||
82 | } // eo namespace Tracer | |
83 | } // eo namespace I2n | |
84 | ||
85 | #endif |