]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/group-interface.cc
Rearranging, editing, clean-up.
[lilypond.git] / lily / group-interface.cc
index 3b6b53e664496f267d213aaec9efb90ae9c583fa..9fbd329e7cf15aacabab9acdca993c4f0a81a57b 100644 (file)
@@ -1,63 +1,57 @@
-/*   
-  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::has_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)
 {
-  p->used_b_ =  true;
-  elt_l_->used_b_ = true;
-  
-  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;
 
-void
-Group_interface::set_interface ()
-{
-  if (!has_interface_b ())
+  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 (unsmob_grob (e));
     }
+
+  arr.reverse ();
+  return arr;
 }
 
-Group_interface
-group (Score_element*s)
+Link_array<Item>
+extract_item_array (Grob const *elt, SCM symbol)
 {
-  Group_interface gi (s);
-  return gi;
+  Link_array<Item> arr;
+  for (SCM s = elt->internal_get_property (symbol); scm_is_pair (s); s = scm_cdr (s))
+    {
+      SCM e = scm_car (s);
+      arr.push (dynamic_cast<Item *> (unsmob_grob (e)));
+    }
+
+  arr.reverse ();
+  return arr;
 }