Coverage Report

Created: 2025-06-20 06:58

/src/PROJ/include/proj/internal/tracing.hpp
Line
Count
Source (jump to first uncovered line)
1
/******************************************************************************
2
 *
3
 * Project:  PROJ
4
 * Purpose:  Tracing/profiling
5
 * Author:   Even Rouault <even dot rouault at spatialys dot com>
6
 *
7
 ******************************************************************************
8
 * Copyright (c) 2019, Even Rouault <even dot rouault at spatialys dot com>
9
 *
10
 * Permission is hereby granted, free of charge, to any person obtaining a
11
 * copy of this software and associated documentation files (the "Software"),
12
 * to deal in the Software without restriction, including without limitation
13
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14
 * and/or sell copies of the Software, and to permit persons to whom the
15
 * Software is furnished to do so, subject to the following conditions:
16
 *
17
 * The above copyright notice and this permission notice shall be included
18
 * in all copies or substantial portions of the Software.
19
 *
20
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26
 * DEALINGS IN THE SOFTWARE.
27
 ****************************************************************************/
28
29
#ifndef TRACING_HH_INCLUDED
30
#define TRACING_HH_INCLUDED
31
32
//! @cond Doxygen_Suppress
33
34
#include <string>
35
36
#include "proj/util.hpp"
37
38
#ifdef ENABLE_TRACING
39
40
NS_PROJ_START
41
42
namespace tracing {
43
44
void logTrace(const std::string &str,
45
              const std::string &component = std::string());
46
47
class EnterBlock {
48
  public:
49
    EnterBlock(const std::string &msg);
50
    ~EnterBlock();
51
52
  private:
53
    PROJ_OPAQUE_PRIVATE_DATA
54
};
55
56
#define TRACING_MERGE(a, b) a##b
57
#define TRACING_UNIQUE_NAME(a) TRACING_MERGE(unique_name_, a)
58
59
#define ENTER_BLOCK(x) EnterBlock TRACING_UNIQUE_NAME(__LINE__)(x)
60
#define ENTER_FUNCTION() ENTER_BLOCK(__FUNCTION__ + std::string("()"))
61
62
} // namespace tracing
63
64
NS_PROJ_END
65
66
using namespace NS_PROJ::tracing;
67
68
#else // ENABLE_TRACING
69
70
0
inline void logTrace(const std::string &, const std::string & = std::string()) {
71
0
}
72
73
#define ENTER_BLOCK(x)                                                         \
74
    do {                                                                       \
75
    } while (0);
76
77
#define ENTER_FUNCTION()                                                       \
78
415k
    do {                                                                       \
79
415k
    } while (0)
80
81
#endif // ENABLE_TRACING
82
83
//! @endcond
84
85
#endif // TRACING_HH_INCLUDED