]> git.donarmstrong.com Git - lilypond.git/blob - src/inputstaff.cc
release: 0.0.17
[lilypond.git] / src / inputstaff.cc
1 #include "getcommand.hh"
2 #include "debug.hh"
3 #include "inputmusic.hh"
4 #include "inputstaff.hh"
5 #include "inputcommands.hh"
6 #include "inputcommand.hh"
7 #include "staffcommands.hh"
8 #include "melodicstaff.hh"
9 #include "rhythmstaff.hh"
10 #include "staff.hh"
11
12 void
13 Input_staff::add(svec<Input_command*> &s)
14 {
15     commands_.bottom().add(get_reset_command());
16     for (int i=0; i < s.sz(); i++)
17         commands_.bottom().add(s[i]);
18     s.set_size(0);
19 }
20
21 Input_staff::Input_staff(String s)
22 {
23     type= s;
24 }
25
26 void
27 Input_staff::add(Input_music*m)
28 {
29     music_.bottom().add(m);
30 }
31
32 Staff*
33 Input_staff::parse(PointerList<Input_command*> score_wide)
34 {
35     Staff *p=0;
36     
37     if (type == "melodic")
38         p = new Melodic_staff;
39     else if (type == "rhythmic")
40         p = new Rhythmic_staff;
41
42     for (PCursor<Input_music*> i(music_); i.ok(); i++) {
43         Voice_list vl = i->convert();
44         p->add(vl);
45     }
46
47     Input_commands commands;
48     for (PCursor<Input_command*> i(score_wide); i.ok(); i++) 
49         commands.add(**i);
50     for (PCursor<Input_command*> i(commands_); i.ok(); i++) 
51         commands.add(**i);
52
53     p->staff_commands_ = commands.parse();
54
55     return p;
56 }
57
58 Input_staff::Input_staff(Input_staff&s)
59 {
60     for (PCursor<Input_command*> i(s.commands_); i.ok(); i++)
61         commands_.bottom().add(new Input_command(**i));
62     for (PCursor<Input_music*> i(s.music_); i.ok(); i++)
63         add(i);
64
65     type = s.type;
66 }
67
68 void
69 Input_staff::print() const
70 {
71 #ifndef NPRINT
72     mtor << "Input_staff {\n";
73     for (PCursor<Input_command*> i(commands_); i.ok(); i++)
74         i->print();
75     for (PCursor<Input_music*> i(music_); i.ok(); i++)
76         i->print();
77     mtor << "}\n";
78 #endif
79 }