]> git.donarmstrong.com Git - lilypond.git/blob - lily/output-property-engraver.cc
release: 1.3.39
[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       /*
48         should typecheck pred. 
49        */
50       SCM result=gh_apply (pred,
51                            gh_list (inf.elem_l_->self_scm_, SCM_UNDEFINED));
52       if (to_boolean (result))
53         {
54           Score_element::ly_set_elt_property (inf.elem_l_->self_scm_,
55                                               gh_cadr (o->pred_sym_val_list_),
56                                               gh_caddr (o->pred_sym_val_list_));
57         }
58     }
59 }
60
61 void
62 Output_property_engraver::do_pre_move_processing ()
63 {
64   props_.clear ();
65 }
66
67 ADD_THIS_TRANSLATOR(Output_property_engraver);