]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/virtual-methods.hh
release: 1.1.6
[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--1998 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 #include "stdlib.h"             // size_t
15
16 #define classname(class_ptr)   demangle_classname(typeid(*(class_ptr)).name())
17
18 const char *
19 demangle_classname (const char*);
20
21 /**
22
23    Virtual copy constructor. Make up for C++'s lack of a standard
24    clone() function.  Uses a typeof hack.  Usage:
25
26    class Foo : Baseclass {
27         VIRTUAL_COPY_CONS(Baseclass);
28    };
29    
30  */
31 #define VIRTUAL_COPY_CONS(base)   virtual base *clone () const { return new typeof(*this) (*this); }
32
33 #endif