xref: /haiku/headers/os/support/ClassInfo.h (revision 4f00613311d0bd6b70fa82ce19931c41f071ea4e)
1 /******************************************************************************
2 /
3 /	File:			ClassInfo.h
4 /
5 /	Description:	C++ class identification and casting macros
6 /
7 /	Copyright 1993-98, Be Incorporated
8 /
9 ******************************************************************************/
10 
11 #ifndef _CLASS_INFO_H
12 #define _CLASS_INFO_H
13 
14 #include <typeinfo>
15 
16 // deprecated, use standard RTTI calls instead
17 
18 #ifdef USE_OPENBEOS_NAMESPACE
19 namespace OpenBeOS {
20 #endif
21 
22 /*-------------------------------------------------------------*/
23 /*--------- Class Info Macros ---------------------------------*/
24 
25 #define class_name(ptr)				((typeid(*(ptr))).name())
26 #define cast_as(ptr, class)			(dynamic_cast<class*>(ptr))
27 #define is_kind_of(ptr, class)		(cast_as(ptr, class) != 0)
28 #define is_instance_of(ptr, class)	(typeid(*(ptr)) == typeid(class))
29 
30 /*-------------------------------------------------------------*/
31 /*-------------------------------------------------------------*/
32 
33 #ifdef USE_OPENBEOS_NAMESPACE
34 }	// namespace OpenBeOS
35 using namespace OpenBeOS;
36 #endif
37 
38 #endif /* _CLASS_INFO_H */
39