2 engraver-group.cc -- implement Engraver_group
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "dispatcher.hh"
11 #include "engraver-group.hh"
13 #include "paper-score.hh"
14 #include "translator-dispatch-list.hh"
17 IMPLEMENT_LISTENER (Engraver_group, override);
19 Engraver_group::override (SCM sev)
21 Stream_event *ev = unsmob_stream_event (sev);
23 execute_general_pushpop_property (context (),
24 ev->get_property ("symbol"),
25 ev->get_property ("property-path"),
26 ev->get_property ("value"));
29 IMPLEMENT_LISTENER (Engraver_group, revert);
31 Engraver_group::revert (SCM sev)
33 Stream_event *ev = unsmob_stream_event (sev);
35 execute_general_pushpop_property (context (),
36 ev->get_property ("symbol"),
37 ev->get_property ("property-path"),
42 Engraver_group::connect_to_context (Context *c)
44 Translator_group::connect_to_context (c);
45 c->event_source ()->add_listener (GET_LISTENER (override), ly_symbol2scm ("Override"));
46 c->event_source ()->add_listener (GET_LISTENER (revert), ly_symbol2scm ("Revert"));
50 Engraver_group::disconnect_from_context ()
52 context ()->event_source ()->remove_listener (GET_LISTENER (override), ly_symbol2scm ("Override"));
53 context ()->event_source ()->remove_listener (GET_LISTENER (revert), ly_symbol2scm ("Revert"));
54 Translator_group::disconnect_from_context ();
58 Engraver_group::announce_grob (Grob_info info)
60 announce_infos_.push_back (info);
62 Engraver_group *dad_eng
63 = context_->get_parent_context ()
64 ? dynamic_cast<Engraver_group *> (context_->get_parent_context ()->implementation ())
68 dad_eng->announce_grob (info);
72 Engraver_group::acknowledge_grobs ()
74 if (!announce_infos_.size ())
77 SCM name_sym = ly_symbol2scm ("name");
78 SCM meta_sym = ly_symbol2scm ("meta");
80 for (vsize j = 0; j < announce_infos_.size (); j++)
82 Grob_info info = announce_infos_[j];
84 SCM meta = info.grob ()->internal_get_property (meta_sym);
85 SCM nm = scm_assoc (name_sym, meta);
91 SCM acklist = scm_hashq_ref (acknowledge_hash_table_drul_[info.start_end ()],
94 Engraver_dispatch_list *dispatch
95 = Engraver_dispatch_list::unsmob (acklist);
97 if (acklist == SCM_BOOL_F)
100 = scm_cdr (scm_assoc (ly_symbol2scm ("interfaces"), meta));
101 acklist = Engraver_dispatch_list::create (get_simple_trans_list (),
102 ifaces, info.start_end ());
105 = Engraver_dispatch_list::unsmob (acklist);
107 scm_hashq_set_x (acknowledge_hash_table_drul_[info.start_end ()], nm, acklist);
111 dispatch->apply (info);
116 Ugh. This is slightly expensive. We could/should cache the value of
120 Engraver_group::pending_grob_count () const
122 int count = announce_infos_.size ();
123 for (SCM s = context_->children_contexts ();
124 scm_is_pair (s); s = scm_cdr (s))
126 Context *c = unsmob_context (scm_car (s));
127 Engraver_group *group
128 = dynamic_cast<Engraver_group *> (c->implementation ());
131 count += group->pending_grob_count ();
137 Engraver_group::do_announces ()
142 DOCME: why is this inside the loop?
144 for (SCM s = context ()->children_contexts ();
145 scm_is_pair (s); s = scm_cdr (s))
147 Context *c = unsmob_context (scm_car (s));
148 Engraver_group *group
149 = dynamic_cast<Engraver_group *> (c->implementation ());
151 group->do_announces ();
157 precomputed_translator_foreach (PROCESS_ACKNOWLEDGED);
158 if (announce_infos_.size () == 0)
161 acknowledge_grobs ();
162 announce_infos_.clear ();
165 while (pending_grob_count () > 0);
168 Engraver_group::Engraver_group ()
170 acknowledge_hash_table_drul_[LEFT]
171 = acknowledge_hash_table_drul_[RIGHT]
174 acknowledge_hash_table_drul_[LEFT] = scm_c_make_hash_table (61);
175 acknowledge_hash_table_drul_[RIGHT] = scm_c_make_hash_table (61);
178 #include "translator.icc"
180 ADD_TRANSLATOR_GROUP (Engraver_group,
182 "A group of engravers taken together.",
195 Engraver_group::derived_mark () const
197 scm_gc_mark (acknowledge_hash_table_drul_[LEFT]);
198 scm_gc_mark (acknowledge_hash_table_drul_[RIGHT]);