lilypond-1.3.147
[lilypond.git] / lily / output-property-engraver.cc
blob7db91b877db2e37e23aa8d2de7d20e45df19f69e
1 /*
2 output-property-engraver.cc -- implement Output_property_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "engraver.hh"
11 #include "grob.hh"
12 #include "output-property-music-iterator.hh"
14 class Output_property_engraver : public Engraver
16 public:
17 VIRTUAL_COPY_CONS (Translator);
18 protected:
21 should do this with \once and \push ?
24 \property Voice.outputProperties \push #pred = #modifier
26 where both MODIFIER and PRED are functions taking a
27 grob.
32 Link_array<Music> props_;
34 virtual void stop_translation_timestep ();
35 virtual void acknowledge_grob (Grob_info);
36 virtual bool try_music (Music*);
40 bool
41 Output_property_engraver::try_music (Music* m)
43 if (m->get_mus_property ("iterator-ctor") ==
44 Output_property_music_iterator::constructor_cxx_function)
46 props_.push (m);
47 return true;
49 return false;
52 void
53 Output_property_engraver::acknowledge_grob (Grob_info inf)
55 for (int i=props_.size (); i--;)
57 Music * o = props_[i];
58 SCM pred = o->get_mus_property ("predicate");
61 should typecheck pred.
63 SCM result=gh_apply (pred,
64 gh_list (inf.elem_l_->self_scm (), SCM_UNDEFINED));
65 if (to_boolean (result))
67 SCM sym = o->get_mus_property ("symbol");
68 SCM val = o->get_mus_property ("value");
69 inf.elem_l_->set_grob_property (sym, val);
74 void
75 Output_property_engraver::stop_translation_timestep ()
77 props_.clear ();
80 ADD_THIS_TRANSLATOR (Output_property_engraver);