]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/virtual-methods.hh
release: 0.0.68pre
[lilypond.git] / flower / include / virtual-methods.hh
1 /*
2   class-name.hh -- declare 
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9
10 #ifndef CLASS_NAME_HH
11 #define CLASS_NAME_HH
12
13 /** a macro to declare the classes name as a static and virtual function.
14   The static_name() can *not* be inlined (this might have the effect that 
15   s->name() != S::static_name(). Overlapping strings need not be merged in C++
16  */
17 #define NAME_MEMBERS()  \
18 static char const *static_name();\
19 virtual bool is_type_b(const char *)const; \
20 virtual char const *name() const{ return static_name(); } \
21 int a_stupid_nonexistent_function_to_allow_the_semicolon_come_out()
22
23 #define IMPLEMENT_STATIC_NAME(c)\
24     char const *c::static_name() { return #c; } 
25
26 #define VIRTUAL_COPY_CONS(T, R)\
27   virtual R *clone() const { return  new T(*this); } \
28
29 #define IMPLEMENT_IS_TYPE_B(D)                                                     \
30   bool D::is_type_b(const char *s)      const                                      \
31 {                                                                                  \
32     return s == static_name();                                                     \
33 }                                                                                  
34                                                                                    
35 #define IMPLEMENT_IS_TYPE_B1(D,B)                                                  \
36   bool D::is_type_b(const char *s)const                                            \
37 {                                                                                  \
38     return s == static_name() || B::is_type_b(s);                                  \
39 }                                                                                  
40 #define IMPLEMENT_IS_TYPE_B2(D, BA, BB)                                                    \
41   bool D::is_type_b(const char *s)      const                                      \
42 {                                                                                  \
43     return s == static_name() || BA::is_type_b(s) || BB::is_type_b(s); \
44 }
45
46 #endif // CLASS-NAME_HH