lilypond-1.3.28
[lilypond.git] / lily / output-property-engraver.cc
blob6f0b6cf88ffb31a972310db79bd78b34b5a20a56
1 /*
2 output-property-engraver.cc -- implement Output_property_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "output-property.hh"
11 #include "engraver.hh"
12 #include "score-element.hh"
14 class Output_property_engraver : public Engraver
16 public:
17 VIRTUAL_COPY_CONS(Translator);
18 protected:
20 Link_array<Output_property> props_;
22 virtual void do_pre_move_processing ();
23 virtual void acknowledge_element (Score_element_info);
24 virtual bool do_try_music (Music*);
28 bool
29 Output_property_engraver::do_try_music (Music* m)
31 if (Output_property * o = dynamic_cast<Output_property*> (m))
33 props_.push (o);
34 return true;
36 return false;
39 void
40 Output_property_engraver::acknowledge_element (Score_element_info inf)
42 for (int i=props_.size (); i--; )
44 Output_property * o = props_[i];
45 SCM pred = gh_car (o->pred_sym_val_list_);
47 should typecheck pred.
49 SCM result=gh_apply (pred,
50 gh_list (inf.elem_l_->self_scm_, SCM_UNDEFINED));
51 if (to_boolean (result))
53 Score_element::ly_set_elt_property (inf.elem_l_->self_scm_,
54 gh_cadr (o->pred_sym_val_list_),
55 gh_caddr (o->pred_sym_val_list_));
60 void
61 Output_property_engraver::do_pre_move_processing ()
63 props_.clear ();
66 ADD_THIS_TRANSLATOR(Output_property_engraver);