]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/virtual-methods.hh
* Another grand 2003 update.
[lilypond.git] / flower / include / virtual-methods.hh
1 /*
2   virtual-methods.hh -- declare macros for our do-it-yourself RTTI
3
4   source file of the Flower Library
5
6   (c)  1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9
10 #ifndef VIRTUAL_METHODS_HH
11 #define VIRTUAL_METHODS_HH
12
13 #include <typeinfo>
14
15 #define classname(class_ptr)   demangle_classname (typeid (* (class_ptr)))
16
17 const char *
18 demangle_classname (std::type_info const &);
19
20 /**
21
22    Virtual copy constructor. Make up for C++'s lack of a standard
23    clone () function.  Uses a typeof hack.  Usage:
24
25    class Foo : Baseclass {
26         VIRTUAL_COPY_CONS (Baseclass);
27    };
28    
29  */
30
31 /*
32   fix constness: gcc-2.95 is correct in defining
33   
34     typeof (*this)
35     
36   in a const member function to be const
37 */
38 #define VIRTUAL_COPY_CONS(base) \
39   virtual base* clone_const_helper () \
40     { \
41       return new typeof (*this) (*this); \
42     } \
43   virtual base* clone () const \
44     { \
45       base* urg = (base*)this; \
46       return urg->clone_const_helper (); \
47     }
48
49
50 #endif /* VIRTUAL_METHODS_HH */