]> git.donarmstrong.com Git - lilypond.git/blobdiff - src/inputstaff.cc
partial: 0.0.38.hanjan
[lilypond.git] / src / inputstaff.cc
index 97622a9dab808840dddf81196bedf73e536a19b1..952af6bd7106ba617acb369e0901727177b11d5c 100644 (file)
@@ -1,26 +1,27 @@
-#include "getcommand.hh"
+/*
+  inputstaff.cc -- implement Input_staff
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
 #include "debug.hh"
+#include "score.hh"
 #include "inputmusic.hh"
 #include "inputstaff.hh"
-#include "inputcommands.hh"
-#include "inputcommand.hh"
-#include "staffcommands.hh"
-#include "melodicstaff.hh"
-#include "rhythmstaff.hh"
 #include "staff.hh"
+#include "complexstaff.hh"
+#include "lyricstaff.hh"
+
+#include "lexer.hh"
 
-void
-Input_staff::add(svec<Input_command*> &s)
-{
-    commands_.bottom().add(get_reset_command());
-    for (int i=0; i < s.sz(); i++)
-       commands_.bottom().add(s[i]);
-    s.set_size(0);
-}
 
 Input_staff::Input_staff(String s)
 {
+    score_wide_music_p_ =0;
     type= s;
+    defined_ch_c_l_ = 0;
 }
 
 void
@@ -30,39 +31,38 @@ Input_staff::add(Input_music*m)
 }
 
 Staff*
-Input_staff::parse(PointerList<Input_command*> score_wide)
+Input_staff::parse(Score*score_l, Input_music *default_score_wide)
 {
     Staff *p=0;
-    
     if (type == "melodic")
-       p = new Melodic_staff;
-    else if (type == "rhythmic")
-       p = new Rhythmic_staff;
+       p = new Complex_staff;
+    else if (type == "lyric")
+       p = new Lyric_staff;
+    else {
+       error( "Unknown staff-type `" + type +"\'", defined_ch_c_l_ );
+       exit( 1 );
+    }
 
+    p->score_l_ = score_l;
+    
     for (iter_top(music_,i); i.ok(); i++) {
        Voice_list vl = i->convert();
        p->add(vl);
     }
-
-    Input_commands commands;
-    for (iter_top(score_wide,i); i.ok(); i++) 
-       commands.add(**i);
-    for (iter_top(commands_,i); i.ok(); i++) 
-       commands.add(**i);
-
-    p->staff_commands_ = commands.parse();
-
+    Voice_list vl =  (score_wide_music_p_) ? score_wide_music_p_->convert()
+       : default_score_wide->convert();
+    p->add(vl);
     return p;
 }
 
-Input_staff::Input_staff(Input_staff&s)
-{
-    for (iter_top(s.commands_,i); i.ok(); i++)
-       commands_.bottom().add(new Input_command(**i));
+Input_staff::Input_staff(Input_staff const&s)
+{    
     for (iter_top(s.music_,i); i.ok(); i++)
-       add(i);
-
+       add(i->clone());
+    defined_ch_c_l_ = s.defined_ch_c_l_;
     type = s.type;
+    score_wide_music_p_ = (s.score_wide_music_p_) ?
+       s.score_wide_music_p_->clone() : 0;
 }
 
 void
@@ -70,10 +70,19 @@ Input_staff::print() const
 {
 #ifndef NPRINT
     mtor << "Input_staff {\n";
-    for (iter_top(commands_,i); i.ok(); i++)
-       i->print();
     for (iter_top(music_,i); i.ok(); i++)
        i->print();
     mtor << "}\n";
 #endif
 }
+void
+Input_staff::set_score_wide(Input_music *m_p)
+{
+    delete score_wide_music_p_;
+    score_wide_music_p_ = m_p;
+}
+
+Input_staff::~Input_staff()
+{
+    delete score_wide_music_p_;
+}