]> git.donarmstrong.com Git - lilypond.git/blob - src/inputstaff.cc
release: 0.0.34
[lilypond.git] / src / inputstaff.cc
1 /*
2   inputstaff.cc -- implement Input_staff
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "debug.hh"
10 #include "score.hh"
11 #include "inputmusic.hh"
12 #include "inputstaff.hh"
13 #include "staff.hh"
14 #include "complexstaff.hh"
15 #include "lyricstaff.hh"
16
17 #include "lexer.hh"
18
19
20 Input_staff::Input_staff(String s)
21 {
22     score_wide_music_p_ =0;
23     type= s;
24     defined_ch_c_l_ = 0;
25 }
26
27 void
28 Input_staff::add(Input_music*m)
29 {
30     music_.bottom().add(m);
31 }
32
33 Staff*
34 Input_staff::parse(Score*score_l, Input_music *default_score_wide)
35 {
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 );
44     }
45
46     p->score_l_ = score_l;
47     
48     for (iter_top(music_,i); i.ok(); i++) {
49         Voice_list vl = i->convert();
50         p->add(vl);
51     }
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;
56 }
57
58 Input_staff::Input_staff(Input_staff const&s)
59 {    
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;
66 }
67
68 void
69 Input_staff::print() const
70 {
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
77 }
78 void
79 Input_staff::set_score_wide(Input_music *m_p)
80 {
81     delete score_wide_music_p_;
82     score_wide_music_p_ = m_p;
83 }
84
85 Input_staff::~Input_staff()
86 {
87     delete score_wide_music_p_;
88 }