-/*
- group-interface.cc -- implement Group_interface
-
+/*
+ group-interface.cc -- implement Group_interface
+
source file of the GNU LilyPond music typesetter
-
- (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+
+ (c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
#include "group-interface.hh"
-#include "score-element.hh"
+#include "item.hh"
-Group_interface::Group_interface (Score_element const* e)
+void
+Group_interface::add_thing (Grob *me, SCM sym, SCM thing)
{
- elt_l_ = (Score_element*)e;
- name_ = "elements";
+ me->add_to_list_property (sym, thing);
}
-
-Group_interface::Group_interface (Score_element const *e, String s)
-{
- elt_l_ =(Score_element*)e;
- name_ = s;
-}
-bool
-Group_interface::supports_interface_b ()
+int
+Group_interface::count (Grob *me, SCM sym)
{
- SCM el = elt_l_->get_elt_property (name_);
-
- return el == SCM_EOL || gh_pair_p (el);
+ return scm_ilength (me->internal_get_property (sym));
}
-
void
-Group_interface::add_element (Score_element*p)
+Pointer_group_interface::add_grob (Grob *me, SCM name, Grob *p)
{
- elt_l_->set_elt_property (name_,
- gh_cons (p->self_scm_, elt_l_->get_elt_property (name_)));
+ Group_interface::add_thing (me, name, p->self_scm ());
}
-int
-Group_interface::count ()
+Link_array<Grob>
+extract_grob_array (Grob const *elt, SCM symbol)
{
- return scm_ilength (elt_l_->get_elt_property (name_));
+ Link_array<Grob> arr;
+
+ for (SCM s = elt->internal_get_property (symbol); scm_is_pair (s); s = scm_cdr (s))
+ {
+ SCM e = scm_car (s);
+ arr.push (unsmob_grob (e));
+ }
+
+ arr.reverse ();
+ return arr;
}
-void
-Group_interface::set_interface ()
+Link_array<Item>
+extract_item_array (Grob const *elt, SCM symbol)
{
- if (!supports_interface_b ())
+ Link_array<Item> arr;
+ for (SCM s = elt->internal_get_property (symbol); scm_is_pair (s); s = scm_cdr (s))
{
- elt_l_->set_elt_property (name_, SCM_EOL);
+ SCM e = scm_car (s);
+ arr.push (dynamic_cast<Item *> (unsmob_grob (e)));
}
+
+ arr.reverse ();
+ return arr;
}