Horizon
Loading...
Searching...
No Matches
3rd_party
router
router
pns_debug_decorator.h
1
/*
2
* KiRouter - a push-and-(sometimes-)shove PCB router
3
*
4
* Copyright (C) 2013-2021 CERN
5
* Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
6
* Author: Christian Gagneraud <chgans@gna.org>
7
*
8
* This program is free software: you can redistribute it and/or modify it
9
* under the terms of the GNU General Public License as published by the
10
* Free Software Foundation, either version 3 of the License, or (at your
11
* option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful, but
14
* WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License along
19
* with this program. If not, see <http://www.gnu.org/licenses/>.
20
*/
21
22
#ifndef __PNS_DEBUG_DECORATOR_H
23
#define __PNS_DEBUG_DECORATOR_H
24
25
#include <math/vector2d.h>
26
#include <math/box2.h>
27
#include <geometry/seg.h>
28
#include <geometry/shape_line_chain.h>
29
30
#include <color4d.h>
31
32
namespace
PNS {
33
34
class
DEBUG_DECORATOR
35
{
36
public
:
37
DEBUG_DECORATOR() : m_debugEnabled(
false
) {}
38
39
struct
SRC_LOCATION_INFO
40
{
41
SRC_LOCATION_INFO(
const
std::string& aFileName =
""
,
const
std::string& aFuncName =
""
,
42
int
aLine = 0 ) :
43
fileName( aFileName ),
44
funcName( aFuncName ),
45
line( aLine )
46
{
47
}
48
49
std::string fileName;
50
std::string funcName;
51
int
line;
52
};
53
54
virtual
~DEBUG_DECORATOR() {}
55
56
void
SetDebugEnabled(
bool
aEnabled ) { m_debugEnabled = aEnabled;}
57
bool
IsDebugEnabled()
const
{
return
m_debugEnabled; }
58
59
virtual
void
SetIteration(
int
iter ){};
60
virtual
void
Message(
const
wxString& msg,
61
const
SRC_LOCATION_INFO
& aSrcLoc =
SRC_LOCATION_INFO
() ){};
62
virtual
void
NewStage(
const
std::string& name,
int
iter,
63
const
SRC_LOCATION_INFO
& aSrcLoc =
SRC_LOCATION_INFO
() ){};
64
virtual
void
BeginGroup(
const
std::string& name,
65
const
SRC_LOCATION_INFO
& aSrcLoc =
SRC_LOCATION_INFO
() ){};
66
virtual
void
EndGroup(
const
SRC_LOCATION_INFO
& aSrcLoc =
SRC_LOCATION_INFO
() ){};
67
virtual
void
AddPoint(
const
VECTOR2I& aP,
const
KIGFX::COLOR4D& aColor,
int
aSize,
68
const
std::string& aName,
69
const
SRC_LOCATION_INFO
& aSrcLoc =
SRC_LOCATION_INFO
() ){};
70
virtual
void
AddLine(
const
SHAPE_LINE_CHAIN& aLine,
const
KIGFX::COLOR4D& aColor,
71
int
aWidth,
const
std::string& aName,
72
const
SRC_LOCATION_INFO
& aSrcLoc =
SRC_LOCATION_INFO
() ){};
73
virtual
void
AddSegment(
const
SEG& aS,
const
KIGFX::COLOR4D& aColor,
74
const
std::string& aName,
75
const
SRC_LOCATION_INFO
& aSrcLoc =
SRC_LOCATION_INFO
() ){};
76
virtual
void
AddBox(
const
BOX2I& aB,
const
KIGFX::COLOR4D& aColor,
77
const
std::string& aName,
78
const
SRC_LOCATION_INFO
& aSrcLoc =
SRC_LOCATION_INFO
() ){};
79
virtual
void
Clear(){};
80
81
private
:
82
83
bool
m_debugEnabled;
84
};
85
86
/* WARNING! The marco below is a remarkably ugly hack, intended to log the
87
call location of the debug calls without having to create the SRC_LOCATION_INFOs every time
88
DEBUG_DECORATOR::Something() is called.
89
90
Also checks if debug is enabled at all prior to calling decorator methods, thus saving some
91
time wasted otherwise for string formatting and copying the geometry. */
92
93
#define PNS_DBG( dbg, method, ... ) \
94
if( dbg && dbg->IsDebugEnabled() ) \
95
dbg->method( __VA_ARGS__, PNS::DEBUG_DECORATOR::SRC_LOCATION_INFO( __FILE__, __FUNCTION__, \
96
__LINE__ ) );
97
98
#define PNS_DBGN( dbg, method ) \
99
if( dbg && dbg->IsDebugEnabled() ) \
100
dbg->method( PNS::DEBUG_DECORATOR::SRC_LOCATION_INFO( __FILE__, __FUNCTION__, __LINE__ ) );
101
102
}
// namespace PNS
103
104
#endif
PNS::DEBUG_DECORATOR::SRC_LOCATION_INFO
Definition
pns_debug_decorator.h:40
Generated by
1.15.0