]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/group-interface.hh
trem fix
[lilypond.git] / lily / include / group-interface.hh
1 /*   
2   group-interface.hh -- declare Group_interface
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1999--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #ifndef GROUP_INTERFACE_HH
11 #define GROUP_INTERFACE_HH
12
13 #include "lily-proto.hh"
14 #include "string.hh"
15 #include "lily-guile.hh"
16
17 #include "grob.hh"
18 /**
19    Look at Score element ELT as thing which has a list property called
20    NAME_. Normally the list would contain Grobs, but
21    sometimes it can be different things.
22
23    todo: reename as list_interface?
24 */
25
26 struct Group_interface
27 {
28 public:
29   static int count (Grob*  , String);
30   static void add_thing (Grob*, SCM, SCM);
31   static void add_thing (Grob*, String nm, SCM);
32 };
33
34 struct Pointer_group_interface : public Group_interface {
35 public:
36   static void add_grob (Grob*, SCM nm, Grob*e);
37 };
38 /** 
39   Put all score elements of ELT's property called NAME into an array,
40   and return it.  */
41
42 inline Link_array<Grob>
43 list_to_grob_array (SCM l)
44 {
45   Link_array<Grob> arr;
46
47   for (SCM s = l; gh_pair_p (s); s = gh_cdr (s))
48     {
49       SCM e = gh_car (s);
50       arr.push (unsmob_grob (e));
51     }
52
53   arr.reverse ();
54   return arr;
55 }
56
57 template<class T>
58 Link_array<T>
59 Pointer_group_interface__extract_grobs (Grob const *elt, T *, const char* name)
60 {
61   Link_array<T> arr;
62
63   for (SCM s = elt->get_grob_property (name); gh_pair_p (s); s = gh_cdr (s))
64     {
65       SCM e = gh_car (s);
66       arr.push (dynamic_cast<T*> (unsmob_grob (e)));
67     }
68
69   arr.reverse ();
70   return arr;
71 }
72
73
74
75
76 #endif /* GROUP_INTERFACE_HH */
77