2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2000--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "engraver.hh"
23 #include "stream-event.hh"
25 #include "translator.icc"
28 class Output_property_engraver : public Engraver
30 TRANSLATOR_DECLARATIONS (Output_property_engraver);
32 vector<Stream_event*> props_;
34 void acknowledge_grob (Grob_info);
35 void listen_apply_output (Stream_event *);
37 void stop_translation_timestep ();
40 // We only run this in the Score context, so all events are likely to
43 Output_property_engraver::listen_apply_output (Stream_event *ev)
45 props_.push_back (ev);
49 Output_property_engraver::acknowledge_grob (Grob_info inf)
51 for (vsize i = props_.size (); i--;)
53 Stream_event *o = props_[i];
54 Context *d = inf.context ();
55 SCM grob = o->get_property ("symbol");
56 if (scm_is_symbol (grob)
57 && ly_symbol2string (grob) != inf.grob ()->name ())
59 SCM typ = o->get_property ("context-type");
60 SCM proc = o->get_property ("procedure");
61 for (Context *c = d; c; c = c->get_parent_context ())
63 if (c->is_alias (typ))
65 inf.grob ()->self_scm (),
73 Output_property_engraver::stop_translation_timestep ()
78 Output_property_engraver::Output_property_engraver (Context *c)
84 Output_property_engraver::boot ()
86 ADD_LISTENER (Output_property_engraver, apply_output);
87 ADD_ACKNOWLEDGER (Output_property_engraver, grob);
90 ADD_TRANSLATOR (Output_property_engraver,
92 "Apply a procedure to any grob acknowledged.",