Fix InstrumentSwitch grob definition.
[lilypond.git] / lily / output-property-engraver.cc
blobcbef4235a16da1ca50f9c75625c9ecd129146c4e
1 /*
2 output-property-engraver.cc -- implement Output_property_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
8 */
10 #include "engraver.hh"
11 #include "context.hh"
12 #include "grob.hh"
13 #include "stream-event.hh"
15 #include "translator.icc"
18 class Output_property_engraver : public Engraver
20 TRANSLATOR_DECLARATIONS (Output_property_engraver);
21 protected:
22 vector<Stream_event*> props_;
24 DECLARE_ACKNOWLEDGER (grob);
25 DECLARE_TRANSLATOR_LISTENER (apply_output);
27 void stop_translation_timestep ();
30 IMPLEMENT_TRANSLATOR_LISTENER (Output_property_engraver, apply_output);
31 void
32 Output_property_engraver::listen_apply_output (Stream_event *ev)
35 UGH. Only swallow the output property event in the context
36 it was intended for. This is inelegant but not inefficient.
38 if (context ()->is_alias (ev->get_property ("context-type")))
39 props_.push_back (ev);
42 void
43 Output_property_engraver::acknowledge_grob (Grob_info inf)
45 for (vsize i = props_.size (); i--;)
47 Stream_event *o = props_[i];
48 Context *d = inf.context ();
49 SCM proc = o->get_property ("procedure");
50 scm_call_3 (proc,
51 inf.grob ()->self_scm (),
52 d->self_scm (),
53 context ()->self_scm ());
57 void
58 Output_property_engraver::stop_translation_timestep ()
60 props_.clear ();
63 Output_property_engraver::Output_property_engraver ()
67 ADD_ACKNOWLEDGER (Output_property_engraver, grob);
68 ADD_TRANSLATOR (Output_property_engraver,
69 /* doc */
70 "Apply a procedure to any grob acknowledged.",
72 /* create */
73 "",
75 /* read */
76 "",
78 /* write */