lilypond-1.3.12
[lilypond.git] / lily / input-engraver.cc
blob938e5b7ad71b8bb08aaa84095bf832b4175fc2b4
1 /*
2 input-engraver.cc -- implement Input_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "debug.hh"
10 #include "engraver.hh"
11 #include "input-engraver.hh"
12 #include "parray.hh"
13 #include "input-engraver.hh"
14 #include "engraver-group.hh"
16 bool
17 Input_engraver::is_name_b(String n)
19 for (int i=0; i < alias_str_arr_.size(); i++)
20 if (alias_str_arr_[i] == n)
21 return true;
22 return false;
25 void
26 Input_engraver::print() const
28 #ifndef NPRINT
29 mtor << "type " << type_str_;
30 mtor << "Consists of ";
31 for (int i=0; i< consists_str_arr_.size(); i++)
32 mtor << consists_str_arr_[i] << ',';
33 mtor << "contains " ;
34 for (iter(contains_igrav_p_list_.top(), i); i.ok(); i++)
35 i->print();
36 #endif
41 Input_engraver *
42 Input_engraver::recursive_find(String nm)
44 if ( is_name_b( nm) )
45 return this;
47 Input_engraver * r =0;
48 iter(contains_igrav_p_list_.top(), i);
49 for (; !r &&i.ok(); i++) {
50 if (i->recursive_find(nm))
51 r = i.ptr();
54 return r;
57 Input_engraver *
58 Input_engraver::find_igrav_l(String nm)
60 for (iter(contains_igrav_p_list_.top(), i); i.ok(); i++)
61 if (i->is_name_b( nm))
62 return i;
64 return 0;
68 Engraver_group_engraver *
69 Input_engraver::get_group_engraver_p()
71 Engraver_group_engraver * grav_p = (Engraver_group_engraver*)
72 get_engraver_p(type_str_);
74 for (int i=0; i < consists_str_arr_.size(); i++) {
75 grav_p->add( get_engraver_p( consists_str_arr_[i]) );
77 grav_p -> igrav_l_ = this;
78 return grav_p;
82 bool
83 Input_engraver::accept_req_b()
85 return ! contains_igrav_p_list_.size();
88 void
89 Input_engraver::add(Input_engraver *ip)
91 contains_igrav_p_list_.bottom().add(ip);
94 Input_engraver*
95 Input_engraver::get_default_igrav_l()
97 if ( contains_igrav_p_list_.size() )
98 return contains_igrav_p_list_.top();
99 else
100 return 0;
104 Input_engraver_list::Input_engraver_list(Input_engraver_list const &s)
106 for (PCursor<Input_engraver*> pc(s); pc.ok(); pc++) {
107 Input_engraver *q = pc;
108 Input_engraver *p=new Input_engraver(*q) ;
109 bottom().add(p);