]> git.donarmstrong.com Git - lilypond.git/blob - lily/output-property-engraver.cc
release: 1.3.27
[lilypond.git] / lily / output-property-engraver.cc
1 /*   
2   output-property-engraver.cc --  implement Output_property_engraver
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include "output-property.hh"
11 #include "engraver.hh"
12 #include "score-element.hh"
13
14 class Output_property_engraver : public Engraver
15 {
16 public:
17   VIRTUAL_COPY_CONS(Translator);
18 protected:
19   
20   Link_array<Output_property> props_;
21
22   virtual void do_pre_move_processing ();
23   virtual void acknowledge_element (Score_element_info);
24   virtual bool do_try_music (Music*);
25 };
26
27
28 bool
29 Output_property_engraver::do_try_music (Music* m)
30 {
31   if (Output_property * o = dynamic_cast<Output_property*> (m))
32     {
33       props_.push (o);
34       return true;
35     }
36   return false;
37 }
38
39 void
40 Output_property_engraver::acknowledge_element (Score_element_info inf)
41 {
42   for (int i=props_.size (); i--; )
43     {
44       Output_property * o = props_[i];
45       SCM pred = gh_car (o->pred_sym_val_list_);
46       /*
47         should typecheck pred. 
48        */
49       SCM result=gh_apply (pred,
50                            gh_list (inf.elem_l_->self_scm_, SCM_UNDEFINED));
51       if (to_boolean (result))
52         {
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_));
56         }
57     }
58 }
59
60 void
61 Output_property_engraver::do_pre_move_processing ()
62 {
63   props_.clear ();
64 }
65
66 ADD_THIS_TRANSLATOR(Output_property_engraver);