]> git.donarmstrong.com Git - lilypond.git/blob - src/inputstaff.cc
release: 0.0.27
[lilypond.git] / src / inputstaff.cc
1 #include "getcommand.hh"
2 #include "debug.hh"
3 #include "score.hh"
4 #include "inputmusic.hh"
5 #include "inputstaff.hh"
6 #include "inputcommand.hh"
7 #include "staffcommands.hh"
8 #include "melodicstaff.hh"
9 #include "rhythmstaff.hh"
10 #include "lyricstaff.hh"
11 #include "staff.hh"
12 #include "complexstaff.hh"
13
14 void
15 Input_staff::add(Array<Input_command*> &s)
16 {
17     commands_.bottom().add(get_reset_command());
18     for (int i=0; i < s.size(); i++)
19         commands_.bottom().add(s[i]);
20     s.set_size(0);
21 }
22
23 Input_staff::Input_staff(String s)
24 {
25     type= s;
26 }
27
28 void
29 Input_staff::add(Input_music*m)
30 {
31     music_.bottom().add(m);
32 }
33
34 Staff*
35 Input_staff::parse(Score*score_l)
36 {
37     Staff *p=0;
38
39     if (type == "simple")
40         p = new Melodic_staff;
41     else if (type == "melodic")
42         p = new Complex_staff;
43     else if (type == "rhythmic")
44         p = new Rhythmic_staff;
45     else if (type == "lyric")
46         p = new Lyric_staff;
47     else
48         error("Unknown staff-type `" + type +"\'");
49     
50     p->score_l_ = score_l;
51     p->define_spot_str_ = define_spot_str_;
52     
53     for (iter_top(music_,i); i.ok(); i++) {
54         Voice_list vl = i->convert();
55         p->add(vl);
56     }
57     
58     {
59         Array<String> mark_arr;
60         Array<Moment> moment_arr;
61         p->get_marks(mark_arr, moment_arr);
62         score_l->add_marks(mark_arr, moment_arr);
63     }
64     
65     return p;
66 }
67
68 Input_staff::Input_staff(Input_staff const&s)
69 {
70     for (iter_top(s.commands_,i); i.ok(); i++)
71         commands_.bottom().add(new Input_command(**i));
72     for (iter_top(s.music_,i); i.ok(); i++)
73         add(i->clone());
74     define_spot_str_ = s.define_spot_str_;
75     type = s.type;
76 }
77
78 void
79 Input_staff::print() const
80 {
81 #ifndef NPRINT
82     mtor << "Input_staff {\n";
83     for (iter_top(commands_,i); i.ok(); i++)
84         i->print();
85     for (iter_top(music_,i); i.ok(); i++)
86         i->print();
87     mtor << "}\n";
88 #endif
89 }