Code

Connector tool: make connectors avoid the convex hull of shapes.
[inkscape.git] / src / debug / logger.h
1 /*
2  * Inkscape::Debug::Logger - debug logging facility
3  *
4  * Authors:
5  *   MenTaLguY <mental@rydia.net>
6  *
7  * Copyright (C) 2005 MenTaLguY
8  *
9  * Released under GNU GPL, read the file 'COPYING' for more information
10  */
12 #ifndef SEEN_INKSCAPE_DEBUG_LOGGER_H
13 #define SEEN_INKSCAPE_DEBUG_LOGGER_H
15 #include "debug/event.h"
17 namespace Inkscape {
19 namespace Debug {
21 class Logger {
22 public:
23     static void init();
25     template <typename EventType>
26     inline static void start() {
27         if (_enabled) {
28             if (_category_mask[EventType::category()]) {
29                 _start(EventType());
30             } else {
31                 _skip();
32             }
33         }
34     }
36     template <typename EventType, typename A>
37     inline static void start(A const &a) {
38         if (_enabled) {
39             if (_category_mask[EventType::category()]) {
40                 _start(EventType(a));
41             } else {
42                 _skip();
43             }
44         }
45     }
47     template <typename EventType, typename A, typename B>
48     inline static void start(A const &a, B const &b) {
49         if (_enabled) {
50             if (_category_mask[EventType::category()]) {
51                 _start(EventType(a, b));
52             } else {
53                 _skip();
54             }
55         }
56     }
58     template <typename EventType, typename A, typename B, typename C>
59     inline static void start(A const &a, B const &b, C const &c) {
60         if (_enabled) {
61             if (_category_mask[EventType::category()]) {
62                 _start(EventType(a, b, c));
63             } else {
64                 _skip();
65             }
66         }
67     }
69     template <typename EventType, typename A, typename B,
70                                   typename C, typename D>
71     inline static void start(A const &a, B const &b, C const &c, D const &d) {
72         if (_enabled) {
73             if (_category_mask[EventType::category()]) {
74                 _start(EventType(a, b, c, d));
75             } else {
76                 _skip();
77             }
78         }
79     }
81     template <typename EventType, typename A, typename B, typename C,
82                                   typename D, typename E>
83     inline static void start(A const &a, B const &b, C const &c,
84                              D const &d, E const &e)
85     {
86         if (_enabled) {
87             if (_category_mask[EventType::category()]) {
88                 _start(EventType(a, b, c, d, e));
89             } else {
90                 _skip();
91             }
92         }
93     }
95     template <typename EventType, typename A, typename B, typename C,
96                                   typename D, typename E, typename F>
97     inline static void start(A const &a, B const &b, C const &c,
98                              D const &d, E const &e, F const &f)
99     {
100         if (_enabled) {
101             if (_category_mask[EventType::category()]) {
102                 _start(EventType(a, b, c, d, e, f));
103             } else {
104                 _skip();
105             }
106         }
107     }
109     template <typename EventType, typename A, typename B, typename C,
110                                   typename D, typename E, typename F,
111                                   typename G>
112     inline static void start(A const &a, B const &b, C const &c, D const &d,
113                              E const &e, F const &f, G const &g)
114     {
115         if (_enabled) {
116             if (_category_mask[EventType::category()]) {
117                 _start(EventType(a, b, c, d, e, f, g));
118             } else {
119                 _skip();
120             }
121         }
122     }
124     template <typename EventType, typename A, typename B, typename C,
125                                   typename D, typename E, typename F,
126                                   typename G, typename H>
127     inline static void start(A const &a, B const &b, C const &c, D const &d,
128                              E const &e, F const &f, G const &g, H const &h)
129     {
130         if (_enabled) {
131             if (_category_mask[EventType::category()]) {
132                 _start(EventType(a, b, c, d, e, f, g, h));
133             } else {
134                 _skip();
135             }
136         }
137     }
139     inline static void finish() {
140         if (_enabled) {
141             _finish();
142         }
143     }
145     template <typename EventType>
146     inline static void write() {
147         start<EventType>();
148         finish();
149     }
151     template <typename EventType, typename A>
152     inline static void write(A const &a) {
153         start<EventType, A>(a);
154         finish();
155     }
157     template <typename EventType, typename A, typename B>
158     inline static void write(A const &a, B const &b) {
159         start<EventType, A, B>(a, b);
160         finish();
161     }
163     template <typename EventType, typename A, typename B, typename C>
164     inline static void write(A const &a, B const &b, C const &c) {
165         start<EventType, A, B, C>(a, b, c);
166         finish();
167     }
169     template <typename EventType, typename A, typename B,
170                                   typename C, typename D>
171     inline static void write(A const &a, B const &b, C const &c, D const &d) {
172         start<EventType, A, B, C, D>(a, b, c, d);
173         finish();
174     }
176     template <typename EventType, typename A, typename B,
177                                   typename C, typename D,
178                                   typename E>
179     inline static void write(A const &a, B const &b, C const &c,
180                              D const &d, E const &e)
181     {
182         start<EventType, A, B, C, D, E>(a, b, c, d, e);
183         finish();
184     }
186     template <typename EventType, typename A, typename B,
187                                   typename C, typename D,
188                                   typename E, typename F>
189     inline static void write(A const &a, B const &b, C const &c,
190                              D const &d, E const &e, F const &f)
191     {
192         start<EventType, A, B, C, D, E, F>(a, b, c, d, e, f);
193         finish();
194     }
196     template <typename EventType, typename A, typename B,
197                                   typename C, typename D,
198                                   typename E, typename F,
199                                   typename G>
200     inline static void write(A const &a, B const &b, C const &c,
201                              D const &d, E const &e, F const &f,
202                              G const &g)
203     {
204         start<EventType, A, B, C, D, E, F, G>(a, b, c, d, e, f, g);
205         finish();
206     }
208     template <typename EventType, typename A, typename B,
209                                   typename C, typename D,
210                                   typename E, typename F,
211                                   typename G, typename H>
212     inline static void write(A const &a, B const &b, C const &c,
213                              D const &d, E const &e, F const &f,
214                              G const &g, H const &h)
215     {
216         start<EventType, A, B, C, D, E, F, G, H>(a, b, c, d, e, f, g, h);
217         finish();
218     }
220     static void shutdown();
222 private:
223     static bool _enabled;
225     static void _start(Event const &event);
226     static void _skip();
227     static void _finish();
229     static bool _category_mask[Event::N_CATEGORIES];
230 };
236 #endif
237 /*
238   Local Variables:
239   mode:c++
240   c-file-style:"stroustrup"
241   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
242   indent-tabs-mode:nil
243   fill-column:99
244   End:
245 */
246 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :