lilypond-0.0.38
[lilypond.git] / src / input-staff.cc
blob9e3958e97e1b40c668d9719835251d06a3cc98d3
1 /*
2 input-staff.cc -- implement Input_staff
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "debug.hh"
10 #include "score.hh"
11 #include "input-music.hh"
12 #include "input-staff.hh"
13 #include "staff.hh"
14 #include "complex-staff.hh"
15 #include "lyricstaff.hh"
17 #include "lexer.hh"
20 Input_staff::Input_staff(String s)
22 score_wide_music_p_ =0;
23 type= s;
24 defined_ch_c_l_ = 0;
27 void
28 Input_staff::add(Input_music*m)
30 music_.bottom().add(m);
33 Staff*
34 Input_staff::parse(Score*score_l, Input_music *default_score_wide)
36 Staff *p=0;
37 if (type == "melodic")
38 p = new Complex_staff;
39 else if (type == "lyric")
40 p = new Lyric_staff;
41 else {
42 error( "Unknown staff-type `" + type +"\'", defined_ch_c_l_ );
43 exit( 1 );
46 p->score_l_ = score_l;
48 for (iter_top(music_,i); i.ok(); i++) {
49 Voice_list vl = i->convert();
50 p->add(vl);
52 Voice_list vl = (score_wide_music_p_) ? score_wide_music_p_->convert()
53 : default_score_wide->convert();
54 p->add(vl);
55 return p;
58 Input_staff::Input_staff(Input_staff const&s)
60 for (iter_top(s.music_,i); i.ok(); i++)
61 add(i->clone());
62 defined_ch_c_l_ = s.defined_ch_c_l_;
63 type = s.type;
64 score_wide_music_p_ = (s.score_wide_music_p_) ?
65 s.score_wide_music_p_->clone() : 0;
68 void
69 Input_staff::print() const
71 #ifndef NPRINT
72 mtor << "Input_staff {\n";
73 for (iter_top(music_,i); i.ok(); i++)
74 i->print();
75 mtor << "}\n";
76 #endif
78 void
79 Input_staff::set_score_wide(Input_music *m_p)
81 delete score_wide_music_p_;
82 score_wide_music_p_ = m_p;
85 Input_staff::~Input_staff()
87 delete score_wide_music_p_;