]> git.donarmstrong.com Git - lilypond.git/blob - src/inputstaff.cc
7fbc37dbac3976c01eac1a0a45dc62752d0888cc
[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 #include "midistaff.hh"
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 if (type == "midi")
42         p = new Midi_staff;
43     else {
44         error( "Unknown staff-type `" + type +"\'", defined_ch_c_l_ );
45         exit( 1 );
46     }
47
48     p->score_l_ = score_l;
49     
50     for (iter_top(music_,i); i.ok(); i++) {
51         Voice_list vl = i->convert();
52         p->add(vl);
53     }
54     Voice_list vl =  (score_wide_music_p_) ? score_wide_music_p_->convert()
55         : default_score_wide->convert();
56     p->add(vl);
57     return p;
58 }
59
60 Input_staff::Input_staff(Input_staff const&s)
61 {    
62     for (iter_top(s.music_,i); i.ok(); i++)
63         add(i->clone());
64     defined_ch_c_l_ = s.defined_ch_c_l_;
65     type = s.type;
66     score_wide_music_p_ = (s.score_wide_music_p_) ?
67         s.score_wide_music_p_->clone() : 0;
68 }
69
70 void
71 Input_staff::print() const
72 {
73 #ifndef NPRINT
74     mtor << "Input_staff {\n";
75     for (iter_top(music_,i); i.ok(); i++)
76         i->print();
77     mtor << "}\n";
78 #endif
79 }
80 void
81 Input_staff::set_score_wide(Input_music *m_p)
82 {
83     delete score_wide_music_p_;
84     score_wide_music_p_ = m_p;
85 }
86
87 Input_staff::~Input_staff()
88 {
89     delete score_wide_music_p_;
90 }