2 staff-regs.cc -- implement Staff_registers
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
8 #include "staff-sym.hh"
9 #include "voice-group-regs.hh"
10 #include "voice-regs.hh"
11 #include "staff-regs.hh"
12 #include "command-request.hh"
15 #include "input-register.hh"
18 Staff_registers::get_staff_info() return inf;
20 inf = Request_register::get_staff_info();
21 inf.staff_sym_l_=staff_sym_l_;
22 inf.c0_position_i_l_ = &c0_position_i_;
25 Staff_registers::Staff_registers(Input_register const*ireg_C)
30 add( ireg_C->get_nongroup_p_arr());
34 /** Magic function which takes a Voice_registers out of one of its own
35 children, and puts it in another. This also handles the push and
38 Staff_registers::change_group(Group_change_req * greq_l,
39 Voice_registers *voice_regs_l,
40 Voice_group_registers * old_group)
43 Voice_registers *regs_p = (old_group)
44 ? (Voice_registers*) old_group->get_register_p(
46 : new Voice_registers(
47 greq_l->voice_l(), ireg_C_->get_ireg_l("Voice_group_registers")
48 ->get_ireg_l("Voice_registers"));
50 String new_str = greq_l->newgroup_str_;
53 old_str = old_group->group_id_str_;
54 if ( new_str[0] == '+') {
55 new_str = old_str + new_str;
56 } else if (new_str[0] == '-') {
57 int idx = old_str.index_last_i('+');
59 new_str = old_str.left_str ( idx );
61 Voice_group_registers * new_group_l = get_group(new_str);
62 new_group_l->add(regs_p);
64 mtor << "processed change_group " << get_staff_info().when()<<"\n";
68 Voice_group_registers *
69 Staff_registers::get_group(String id)
71 for (int i=0; i < group_l_arr_.size(); i++) {
72 if (group_l_arr_[i]->group_id_str_ == id)
73 return group_l_arr_[i];
75 Voice_group_registers *group_p =
76 new Voice_group_registers(id, ireg_C_->get_ireg_l("Voice_group_registers"));
77 group_l_arr_.push(group_p);
84 Staff_registers::terminate_register(Request_register * reg)
86 for (int i=0; i < group_l_arr_.size(); i++) {
87 if (group_l_arr_[i] == reg) {
89 Register_group_register::terminate_register(reg);
97 Staff_registers::try_request(Request * r)
99 bool b = Register_group_register::try_request(r);
101 Command_req * cr_l = r->command() ;
103 if (cr_l && cr_l->groupchange()) {
104 change_group(cr_l->groupchange(), 0, 0);
112 IMPLEMENT_STATIC_NAME(Staff_registers);
115 Staff_registers::acceptable_request_b(Request*r)const
117 return Register_group_register::acceptable_request_b(r) ||
118 (r->command() && r->command()->groupchange());
122 Staff_registers::acknowledge_element(Staff_elem_info i)
124 Register_group_register::acknowledge_element(i);
125 if ( i.elem_l_->name() == Staff_symbol::static_name())
126 staff_sym_l_ = (Staff_symbol*)i.elem_l_;