X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Finclude%2Fgroup-interface.hh;h=5ee3a085e59d54f5ede1f9cf3fc9a70556013425;hb=f9efd2c54b174591fa42889557686c7aea356547;hp=fc832a5426096ea626327977638eeb79eccf4db2;hpb=163503e56aa0c03d41d37fd083bdb96a6a473a11;p=lilypond.git diff --git a/lily/include/group-interface.hh b/lily/include/group-interface.hh index fc832a5426..5ee3a085e5 100644 --- a/lily/include/group-interface.hh +++ b/lily/include/group-interface.hh @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1999 Han-Wen Nienhuys + (c) 1999--2002 Han-Wen Nienhuys */ @@ -13,37 +13,57 @@ #include "lily-proto.hh" #include "string.hh" #include "lily-guile.hh" -#include "smobs.hh" + +#include "grob.hh" +/** + Look at Score element ELT as thing which has a list property called + NAME_. Normally the list would contain Grobs, but + sometimes it can be different things. + + todo: reename as list_interface? +*/ struct Group_interface { - Score_element * elt_l_; - String name_; public: - Group_interface (Score_element const*); - Group_interface (Score_element const*, String); - int count (); - bool has_interface_b (); - void set_interface (); - void add_element (Score_element*); + static int count (Grob* , String); + static void add_thing (Grob*, SCM, SCM); + static void add_thing (Grob*, String nm, SCM); }; -/* - template - Link_array Group_interface__extract_elements (T *, String name); -*/ +struct Pointer_group_interface : public Group_interface { +public: + static void add_grob (Grob*, SCM nm, Grob*e); +}; +/** + Put all score elements of ELT's property called NAME into an array, + and return it. */ + +inline Link_array +list_to_grob_array (SCM l) +{ + Link_array arr; + + for (SCM s = l; gh_pair_p (s); s = gh_cdr (s)) + { + SCM e = gh_car (s); + arr.push (unsmob_grob (e)); + } + + arr.reverse (); + return arr; +} + template Link_array -Group_interface__extract_elements (Score_element const *elt, T *, String name) +Pointer_group_interface__extract_grobs (Grob const *elt, T *, const char* name) { Link_array arr; - for (SCM s = elt->get_elt_property (name); gh_pair_p (s); s = gh_cdr (s)) + for (SCM s = elt->get_grob_property (name); gh_pair_p (s); s = gh_cdr (s)) { SCM e = gh_car (s); - assert (SMOB_IS_TYPE_B(Score_element,e)); - Score_element* se = SMOB_TO_TYPE(Score_element, e); - arr.push (dynamic_cast (se)); + arr.push (dynamic_cast (unsmob_grob (e))); } arr.reverse ();