lilypond-1.3.69
[lilypond.git] / lily / output-property-engraver.cc
blobebbb40b6b62c5987ba1cdf60a61edda5ece3839c
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_);
48 should typecheck pred.
50 SCM result=gh_apply (pred,
51 gh_list (inf.elem_l_->self_scm_, SCM_UNDEFINED));
52 if (to_boolean (result))
54 inf.elem_l_->set_elt_property (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);