2 registergroup.cc -- implement Register_group_register
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
11 #include "register-group.hh"
12 #include "register.hh"
15 #include "score-elem.hh"
16 #include "input-register.hh"
18 Register_group_register::~Register_group_register()
20 assert(removable_b());
24 Register_group_register::check_removal()
26 for (int i
=0; i
< group_l_arr_
.size(); ) {
27 group_l_arr_
[i
]->check_removal();
28 if (group_l_arr_
[i
]->removable_b())
29 terminate_register(group_l_arr_
[i
]);
37 Register_group_register::removable_b()const
39 return !iterator_count_
&& !group_l_arr_
.size() ;
42 Register_group_register::Register_group_register()
48 Register_group_register::set_feature(Feature d
)
50 iter_top(reg_list_
, i
);
52 // this construction to ensure clean deletion
53 Request_register
*reg_l
= i
++;
54 reg_l
->set_feature(d
);
59 Register_group_register::sync_features()
61 iter_top(reg_list_
, i
);
64 Request_register
*reg_l
= i
++;
65 reg_l
->sync_features();
70 Register_group_register::do_pre_move_processing()
72 iter_top(reg_list_
, i
);
75 Request_register
*reg_l
= i
++;
76 reg_l
->pre_move_processing();
81 Register_group_register::do_process_requests()
83 iter_top(reg_list_
, i
);
86 Request_register
*reg_l
= i
++;
87 reg_l
->process_requests();
93 Register_group_register::do_post_move_processing()
95 iter_top(reg_list_
, i
);
97 // this construction to ensure clean deletion
98 Request_register
*reg_l
= i
++;
99 reg_l
->post_move_processing();
105 Register_group_register::contains_b(Request_register
* reg_l
)const
107 bool parent_b
= Request_register::contains_b(reg_l
);
111 for (iter_top(reg_list_
, j
); j
.ok(); j
++)
112 if (j
->contains_b(reg_l
))
120 Register_group_register::do_try_request(Request
*req_l
)
122 bool hebbes_b
=false;
123 for (int i
=0; !hebbes_b
&& i
< nongroup_l_arr_
.size() ; i
++)
124 hebbes_b
=nongroup_l_arr_
[i
]->try_request(req_l
);
126 hebbes_b
= daddy_reg_l_
->try_request(req_l
);
131 Register_group_register::add(Request_register
*reg_p
)
133 reg_list_
.bottom().add(reg_p
);
134 reg_p
->daddy_reg_l_
= this;
136 if (reg_p
->is_type_b(Register_group_register::static_name())) {
137 group_l_arr_
.push((Register_group_register
*)reg_p
);
139 nongroup_l_arr_
.push(reg_p
);
145 Register_group_register::remove_register_p(Request_register
*reg_l
)
147 group_l_arr_
.substitute((Register_group_register
*)reg_l
,0);
148 nongroup_l_arr_
.substitute(reg_l
,0);
149 iterator(reg_list_
) reg_cur
= reg_list_
.find(reg_l
);
151 return reg_cur
.remove_p();
155 Register_group_register::terminate_register(Request_register
*r_l
)
157 mtor
<< "Removing " << r_l
->name() << " at " << get_staff_info().when() << "\n";
158 r_l
->do_removal_processing();
159 Request_register
* reg_p
=remove_register_p(r_l
);
164 IMPLEMENT_IS_TYPE_B2(Register_group_register
,Request_register
, Acceptor
);
165 IMPLEMENT_STATIC_NAME(Register_group_register
);
166 ADD_THIS_REGISTER(Register_group_register
);
169 Register_group_register::do_print()const
172 mtor
<< "ID: " << id_str_
<< "\n";
173 for (iter_top(reg_list_
, i
); i
.ok(); i
++)
179 Register_group_register
*
180 Register_group_register::find_register_l(String n
, String id
)
182 if (name() == n
&& id_str_
== id
)
184 Register_group_register
* r
= 0;
185 for (int i
=0; !r
&& i
< group_l_arr_
.size(); i
++) {
186 r
= group_l_arr_
[i
]->find_register_l(n
,id
);
193 Register_group_register::find_get_acceptor_l(String n
,String id
)
196 Input_register
* ireg_l
= ireg_l_
-> recursive_find ( n
);
198 ret
= find_register_l(n
,id
);
200 Register_group_register
* group
=
201 ireg_l
-> get_group_register_p();
206 if (group
->ireg_l_
->is_name_b( n
) )
209 return ret
->find_get_acceptor_l(n
,id
);
212 } else if (daddy_reg_l_
)
213 ret
=daddy_reg_l_
->find_get_acceptor_l(n
,id
);
215 warning("Can't find or create `" + n
+ "' called `" + id
+ "'\n");
222 Register_group_register::depth_i()const
224 return daddy_reg_l_
->depth_i() + 1;
228 Register_group_register::ancestor_l(int l
)
230 if (!l
|| !daddy_reg_l_
)
233 return daddy_reg_l_
->ancestor_l(l
-1);
237 Register_group_register::announce_element(Score_elem_info info
)
239 announce_info_arr_
.push(info
);
240 Request_register::announce_element(info
);
244 Register_group_register::do_announces()
246 for (int i
=0; i
< group_l_arr_
.size(); i
++) {
247 group_l_arr_
[i
]->do_announces();
252 for (int j
=0; j
< announce_info_arr_
.size(); j
++){
253 Score_elem_info info
= announce_info_arr_
[j
];
256 info
.req_l_
= &dummy_req
;
257 for (int i
=0; i
< nongroup_l_arr_
.size(); i
++) {
258 if (nongroup_l_arr_
[i
] != info
.origin_reg_l_arr_
[0])
259 nongroup_l_arr_
[i
]->acknowledge_element(info
);
262 announce_info_arr_
.set_size(0);
267 Register_group_register::do_removal_processing()
269 for (iter( reg_list_
.top(), i
); i
.ok(); i
++)
270 i
->do_removal_processing();
274 Register_group_register::get_staff_info()const
276 Staff_info inf
= Request_register::get_staff_info();
278 for (int i
=0; i
< nongroup_l_arr_
.size(); i
++)
279 nongroup_l_arr_
[i
]->fill_staff_info(inf
);
285 Register_group_register::get_default_interpreter()
287 if ( interpreter_l() )
288 return daddy_reg_l_
->get_default_interpreter();
290 Register_group_register
*reg_p
= ireg_l_
->
291 get_default_ireg_l()->get_group_register_p();
293 if (reg_p
->interpreter_l())
296 return reg_p
->get_default_interpreter();