]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/group-interface.hh
3cdcfedf361a54ab3b8780548d5c72310813c45c
[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--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #ifndef GROUP_INTERFACE_HH
11 #define GROUP_INTERFACE_HH
12
13 #include "grob.hh"
14 #include "string.hh"
15 /**
16    Look at Score element ELT as thing which has a list property called
17    NAME_. Normally the list would contain Grobs, but
18    sometimes it can be different things.
19
20    todo: reename as list_interface?
21 */
22
23 struct Group_interface
24 {
25 public:
26   static int count (Grob*, SCM);
27   static void add_thing (Grob*, SCM, SCM);
28 };
29
30 struct Pointer_group_interface : public Group_interface {
31 public:
32   static void add_grob (Grob*, SCM nm, Grob*e);
33 };
34
35 template<class T>
36 Link_array<T>
37 Pointer_group_interface__extract_grobs (Grob const *elt, T *, const char* name)
38 {
39   Link_array<T> arr;
40
41   for (SCM s = elt->get_property (name); scm_is_pair (s); s = scm_cdr (s))
42     {
43       SCM e = scm_car (s);
44       arr.push (dynamic_cast<T*> (unsmob_grob (e)));
45     }
46
47   arr.reverse ();
48   return arr;
49 }
50
51
52
53
54 #endif /* GROUP_INTERFACE_HH */
55