X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=flower%2Finclude%2Fvirtual-methods.hh;h=b3b9cf008ec084c74d3a00e2b6d9767e2ea76ab4;hb=38d7d319eabc906e82fb42002678c6d42a23b6f7;hp=c7746c84f8aad671bc28638c8145faa6587eeb49;hpb=2c22efe5a46a37065b10c3f51c5d7db00d07d318;p=lilypond.git diff --git a/flower/include/virtual-methods.hh b/flower/include/virtual-methods.hh index c7746c84f8..b3b9cf008e 100644 --- a/flower/include/virtual-methods.hh +++ b/flower/include/virtual-methods.hh @@ -3,28 +3,39 @@ source file of the Flower Library - (c) 1997--2005 Han-Wen Nienhuys + (c) 1997--2009 Han-Wen Nienhuys */ #ifndef VIRTUAL_METHODS_HH #define VIRTUAL_METHODS_HH #include +using namespace std; #define classname(class_ptr) demangle_classname (typeid (* (class_ptr))) char const * -demangle_classname (std::type_info const &); +demangle_classname (type_info const &); -/* Virtual copy constructor. Make up for C++'s lack of a standard - factory or clone () function. Uses a typeof hack. Usage: +/* + +Virtual copy constructor. Make up for C++'s lack of a standard +factory or clone () function. Usage: + +class Foo : Baseclass +{ +VIRTUAL_COPY_CONSTRUCTOR (Baseclass, Foo); +}; + +*/ - class Foo : Baseclass - { - VIRTUAL_COPY_CONSTRUCTOR (Baseclass, Foo); - }; */ +#define DECLARE_CLASSNAME(name) \ + virtual const char *class_name () const { \ + return #name; \ +} #define VIRTUAL_COPY_CONSTRUCTOR(Base, name) \ + DECLARE_CLASSNAME(name);\ virtual Base *clone () const \ { \ return new name (*this); \