]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/group-interface.hh
release: 1.3.59
[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--2000 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 #include "smobs.hh"
17
18 /**
19    Look at Score element ELT as thing which has a list property called
20    NAME_. Normally the list would contain Score_elements, but
21    sometimes it can be different things.
22
23    todo: reename as list_interface?
24 */
25
26 struct Group_interface
27 {
28   Score_element * elt_l_;
29   String name_;
30 public:
31   Group_interface (Score_element const*);
32   Group_interface (Score_element const*, String);
33   int count ();
34   void add_thing (SCM);
35   bool has_interface_b ();
36   void set_interface ();
37 };
38
39 struct Pointer_group_interface {
40   Score_element * elt_l_;
41   String name_;
42 public:
43   Pointer_group_interface (Score_element const*);
44   Pointer_group_interface (Score_element const*, String);
45   int count ();
46   void set_interface ();
47   bool has_interface_b ();
48   void add_element (Score_element*);
49 };
50 /** 
51   Put all score elements of ELT's property called NAME into an array,
52   and return it.  */
53 template<class T>
54 Link_array<T>
55 Pointer_group_interface__extract_elements (Score_element const *elt, T *, const char* name)
56 {
57   Link_array<T> arr;
58
59   for (SCM s = elt->get_elt_pointer (name); gh_pair_p (s); s = gh_cdr (s))
60     {
61       SCM e = gh_car (s);
62       arr.push (dynamic_cast<T*> (unsmob_element (e)));
63     }
64
65   arr.reverse ();
66   return arr;
67 }
68
69
70
71
72 #endif /* GROUP_INTERFACE_HH */
73