2 pointer-group-interface.cc -- implement Pointer_group_interface
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "pointer-group-interface.hh"
11 #include "grob-array.hh"
15 Pointer_group_interface::count (Grob *me, SCM sym)
17 Grob_array *arr = unsmob_grob_array (me->internal_get_object (sym));
18 return arr ? arr->size () : 0;
22 Pointer_group_interface::add_grob (Grob *me, SCM sym, SCM p)
24 add_grob (me, sym, unsmob_grob (p));
28 Pointer_group_interface::set_ordered (Grob *me, SCM sym, bool ordered)
30 Grob_array *arr = get_grob_array (me, sym);
31 arr->set_ordered (ordered);
35 Pointer_group_interface::get_grob_array (Grob *me, SCM sym)
37 SCM scm_arr = me->internal_get_object (sym);
38 Grob_array *arr = unsmob_grob_array (scm_arr);
41 scm_arr = Grob_array::make_array ();
42 arr = unsmob_grob_array (scm_arr);
43 me->set_object (sym, scm_arr);
49 Pointer_group_interface::find_grob (Grob *me, SCM sym, bool (*pred) (Grob*))
51 Grob_array *arr = get_grob_array (me, sym);
53 for (vsize i = 0; i < arr->size (); i++)
54 if (pred (arr->grob (i)))
61 Pointer_group_interface::add_grob (Grob *me, SCM sym, Grob *p)
63 Grob_array *arr = get_grob_array (me, sym);
68 Pointer_group_interface::add_unordered_grob (Grob *me, SCM sym, Grob *p)
70 Grob_array *arr = get_grob_array (me, sym);
72 arr->set_ordered (false);
75 static vector<Grob*> empty_array;
78 ly_scm2link_array (SCM x)
80 Grob_array *arr = unsmob_grob_array (x);
81 return arr ? arr->array () : empty_array;
85 internal_extract_grob_array (Grob const *elt, SCM symbol)
88 ? ly_scm2link_array (elt->internal_get_object (symbol))
93 internal_extract_item_array (Grob const *elt, SCM symbol)
95 Grob_array *arr = unsmob_grob_array (elt->internal_get_object (symbol));
97 for (vsize i = 0; arr && i < arr->size (); i++)
98 items.push_back (arr->item (i));