refresh dc9ccb8c0bf4bc198802d4d39ad2bc523eb5e06f
[tagua/yd.git] / src / core / taguacast.h
blobe2dbf1be14de0b85fe98fd3fd06e19d8a0fd157c
1 /*
2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2007 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #ifndef CORE__TAGUA_CAST_H
12 #define CORE__TAGUA_CAST_H
14 #include <KDebug>
16 #define CAT_AUX(x, y) x ## y
17 #define CAT(x, y) CAT_AUX(x, y)
19 #ifdef TAGUA_DEBUG
20 #define TAGUA_CAST(ID, TYPE, RETVAL) \
21 TYPE* ID = dynamic_cast<TYPE*>(CAT(ID, _)); \
22 if (!ID) { \
23 kWarning("Mismatch!!"); \
24 return RETVAL; \
26 #else
27 #define TAGUA_CAST(ID, TYPE, RETVAL) \
28 TYPE* ID = static_cast<TYPE*>(CAT(ID, _));
29 #endif
31 #endif // CORE__TAGUA_CAST_H