2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: rtti.h /main/1 1996/07/29 17:09:50 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
28 #define rtti_INCLUDED 1
32 #define DYNAMIC_CAST_PTR(T, p) dynamic_cast<T *>(p)
33 #define DYNAMIC_CAST_CONST_PTR(T, p) dynamic_cast<const T *>(p)
38 #define RTTI_DEF1(T, B1)
39 #define RTTI_DEF2(T, B1, B2)
40 #define RTTI_DEF3(T, B1, B2, B3)
42 #else /* not SP_HAVE_RTTI */
48 virtual TypeId dynamicType() const; \
49 static inline TypeId staticType() { return TypeId(RTTI_bases_); } \
51 static const void *RTTI_bases_[]; \
54 #define RTTI_DEF0(T) \
55 const void *T::RTTI_bases_[] = { 0 }; \
56 TypeId T::dynamicType() const { return staticType(); }
58 #define RTTI_DEF1(T, B1) \
59 const void *T::RTTI_bases_[] = { B1::RTTI_bases_, 0 }; \
60 TypeId T::dynamicType() const { return staticType(); }
62 #define RTTI_DEF2(T, B1, B2) \
63 const void *T::RTTI_bases_[] = { B1::RTTI_bases_, B2::RTTI_bases_, 0 }; \
64 TypeId T::dynamicType() const { return staticType(); }
66 #define RTTI_DEF3(T, B1, B2, B3) \
67 const void *T::RTTI_bases_[] = { \
68 B1::RTTI_bases_, B2::RTTI_bases_, B3::RTTI_bases_, 0 }; \
69 TypeId T::dynamicType() const { return staticType(); }
71 #define DYNAMIC_CAST_PTR(T, p) \
72 ((p) && (p)->dynamicType().canCast(T::staticType(), (p)->staticType()) \
75 #define DYNAMIC_CAST_CONST_PTR(T, p) \
76 ((p) && (p)->dynamicType().canCast(T::staticType(), (p)->staticType()) \
80 #endif /* not SP_HAVE_RTTI */
82 #endif /* not rtti_INCLUDED */