lilypond-0.1.37
[lilypond.git] / lily / input-register.cc
blobd1a8b584e36047f25fb1b7a8ed860a3483986767
1 /*
2 input-register.cc -- implement Input_register
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 "register.hh"
11 #include "input-register.hh"
12 #include "parray.hh"
13 #include "input-register.hh"
14 #include "register-group.hh"
16 bool
17 Input_register::is_name_b(String n)
19 bool b = (n == name_str_);
20 for (int i=0; !b && i < alias_str_arr_.size(); i++)
21 b = b || (alias_str_arr_[i] == n);
22 return b;
25 void
26 Input_register::print() const
28 #ifndef NPRINT
29 mtor << "name " << name_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_ireg_p_list_.top(), i); i.ok(); i++)
35 i->print();
36 #endif
40 UGH. Global.
42 Link_array<Input_register> iregs_p_arr;
44 void
45 add_global_input_register(Input_register *reg_p)
47 iregs_p_arr.push(reg_p);
50 Input_register *
51 lookup_reg(String nm)
53 for (int i=0; i < iregs_p_arr.size(); i++)
54 if (iregs_p_arr[i]->is_name_b(nm))
55 return iregs_p_arr[i];
57 error("can't find reg `" + nm + "'");
62 Input_register *
63 Input_register::recursive_find(String nm)
65 if ( is_name_b( nm) )
66 return this;
68 Input_register * r =0;
69 for (iter(contains_ireg_p_list_.top(), i); !r &&i.ok(); i++)
70 r = i->recursive_find(nm);
72 return r;
74 Input_register *
75 Input_register::find_ireg_l(String nm)
77 for (iter(contains_ireg_p_list_.top(), i); i.ok(); i++)
78 if (i->is_name_b( nm))
79 return i;
81 return 0;
85 Register_group_register *
86 Input_register::get_group_register_p()
88 Register_group_register * reg_p = (Register_group_register*)
89 get_register_p(name_str_);
93 for (int i=0; i < consists_str_arr_.size(); i++) {
94 reg_p->add( get_register_p( consists_str_arr_[i]) );
96 reg_p -> ireg_l_ = this;
97 return reg_p;
101 bool
102 Input_register::accept_req_b()
104 return ! contains_ireg_p_list_.size();
107 void
108 Input_register::add(Input_register *ip)
110 contains_ireg_p_list_.bottom().add(ip);
113 Input_register*
114 Input_register::get_default_ireg_l()
116 return contains_ireg_p_list_.top();