2 engraver-group.cc -- implement Engraver_group
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "engraver-group.hh"
12 #include "paper-score.hh"
15 #include "translator-dispatch-list.hh"
18 Engraver_group::announce_grob (Grob_info info)
20 announce_infos_.push (info);
22 Engraver_group *dad_eng
23 = context_->get_parent_context ()
24 ? dynamic_cast<Engraver_group *> (context_->get_parent_context ()->implementation ())
27 dad_eng->announce_grob (info);
31 Engraver_group::acknowledge_grobs ()
33 if (!announce_infos_.size ())
36 SCM name_sym = ly_symbol2scm ("name");
37 SCM meta_sym = ly_symbol2scm ("meta");
39 for (int j = 0; j < announce_infos_.size (); j++)
41 Grob_info info = announce_infos_[j];
43 SCM meta = info.grob ()->internal_get_property (meta_sym);
44 SCM nm = scm_assoc (name_sym, meta);
50 SCM acklist = scm_hashq_ref (acknowledge_hash_table_, nm, SCM_BOOL_F);
51 Engraver_dispatch_list *dispatch
52 = Engraver_dispatch_list::unsmob (acklist);
54 if (acklist == SCM_BOOL_F)
57 = scm_cdr (scm_assoc (ly_symbol2scm ("interfaces"), meta));
58 acklist = Engraver_dispatch_list::create (get_simple_trans_list (),
62 = Engraver_dispatch_list::unsmob (acklist);
64 scm_hashq_set_x (acknowledge_hash_table_, nm, acklist);
68 dispatch->apply (info);
73 Ugh. This is slightly expensive. We could/should cache the value of
77 Engraver_group::pending_grob_count () const
79 int count = announce_infos_.size ();
80 for (SCM s = context_->children_contexts ();
81 scm_is_pair (s); s = scm_cdr (s))
83 Context *c = unsmob_context (scm_car (s));
85 = dynamic_cast<Engraver_group *> (c->implementation ());
88 count += group->pending_grob_count ();
94 Engraver_group::do_announces ()
99 DOCME: why is this inside the loop?
101 for (SCM s = context ()->children_contexts ();
102 scm_is_pair (s); s = scm_cdr (s))
104 Context *c = unsmob_context (scm_car (s));
105 Engraver_group *group
106 = dynamic_cast<Engraver_group *> (c->implementation ());
108 group->do_announces ();
114 precomputed_translator_foreach (PROCESS_ACKNOWLEDGED);
115 if (announce_infos_.size () == 0)
118 acknowledge_grobs ();
119 announce_infos_.clear ();
122 while (pending_grob_count () > 0);
125 Engraver_group::Engraver_group ()
127 acknowledge_hash_table_ = SCM_EOL;
128 acknowledge_hash_table_ = scm_c_make_hash_table (61);
131 #include "translator.icc"
133 ADD_TRANSLATOR_GROUP (Engraver_group,
134 /* doc */ "A group of engravers taken together",
141 Engraver_group::derived_mark () const
143 scm_gc_mark (acknowledge_hash_table_);