Adaptagrams
debug.h
1 /*
2  * vim: ts=4 sw=4 et tw=0 wm=0
3  *
4  * libavoid - Fast, Incremental, Object-avoiding Line Router
5  *
6  * Copyright (C) 2004-2008 Monash University
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  * See the file LICENSE.LGPL distributed with the library.
13  *
14  * Licensees holding a valid commercial license may use this file in
15  * accordance with the commercial license agreement provided with the
16  * library.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21  *
22  * Author(s): Michael Wybrow
23 */
24 
25 
26 #ifndef AVOID_DEBUG_H
27 #define AVOID_DEBUG_H
28 
29 
30 #if defined(_MSC_VER) && defined(USE_ATLTRACE)
31  // Using Microsoft Visual C++ compiler and we want to use ATLTRACE
32  // to send warnings and error messages to a GUI window.
33 
34  // Prevent inclusion of min and max macros.
35  #define NOMINMAX
36 
37  #include <afx.h>
38 #endif
39 
40 #include <cstdarg>
41 #include <cstdio>
42 #include <iostream>
43 
44 
45 namespace Avoid {
46 
47 // db_printf is debugging output for verifying behaviour of the router:
48 #ifdef LIBAVOID_DEBUG
49 
50  #if defined(_MSC_VER) && defined(USE_ATLTRACE)
51  #define db_printf ATL::AtlTrace
52  #else
53  inline void db_printf(const char *fmt, ...)
54  {
55  va_list ap;
56  va_start(ap, fmt);
57  vfprintf(stdout, fmt, ap);
58  va_end(ap);
59  }
60  #endif
61 
62 #else
63 
64  inline void db_printf(const char *, ...)
65  {
66  }
67 
68 #endif
69 
70 // err_printf are critical errors that mean something pretty bad has happened:
71 #if defined(_MSC_VER) && defined(USE_ATLTRACE)
72 
73  #define err_printf ATL::AtlTrace
74 
75 #else
76 
77  // For other environments we always show these errors.
78  inline void err_printf(const char *fmt, ...)
79  {
80  va_list ap;
81  va_start(ap, fmt);
82  vfprintf(stderr, fmt, ap);
83  va_end(ap);
84  }
85 
86 #endif
87 
88 }
89 
90 // Precision of numbers in libavoid SVG debug file. Used in printf
91 // strings ("%" PREC "g"), e.g., "%.16g"
92 #if defined(HIGH_PRECISION_DEBUG)
93  #define PREC ".16"
94 #else
95  #define PREC ""
96 #endif
97 
98 #endif
99 
100 
libavoid: Object-avoiding orthogonal and polyline connector routing library.
Definition: actioninfo.cpp:33