]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.14
authorfred <fred>
Wed, 4 Dec 1996 19:43:25 +0000 (19:43 +0000)
committerfred <fred>
Wed, 4 Dec 1996 19:43:25 +0000 (19:43 +0000)
hdr/getcommand.hh
hdr/inputcommands.hh
hdr/inputscore.hh [new file with mode: 0644]
src/inputscore.cc [new file with mode: 0644]
src/inputstaff.cc [new file with mode: 0644]
src/template3.cc

index b1af2699e2793c160b07f56eabbb1689dc85e8b4..eb6f624966fa117bb15f9febdbfe3d71aee06239 100644 (file)
@@ -1,8 +1,16 @@
-Command*get_clef_interpret_command(String w);
-Command *get_bar_command(Real);
-Command* get_meterchange_command( int,int);
+/*
+  getcommand.hh -- part of LilyPond
+
+  (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef GETCOMMAND_HH
+#define GETCOMMAND_HH
+#include "proto.hh"
+
+
 Command* get_meter_command( Real,int,int);
-Command* get_skip_command( int,Real);
-Command* get_key_interpret_command(svec<String>);
-Command *get_reset_command();
-Command*get_partial_command(Real u);
+
+
+
+#endif // GETCOMMAND_HH
index 8222f9b74fc780862f5402372f9562ca8626a03d..083c830aa9d0899f39bb89e3e446ae2dde523810 100644 (file)
@@ -11,7 +11,8 @@
 #include "plist.hh"
 #include "real.hh"
 
-struct Input_cursor : public PCursor<Command*>
+
+struct Input_cursor : public PCursor<Input_command*>
 {
     /// current measure info
     Real whole_per_measure;
@@ -24,22 +25,22 @@ struct Input_cursor : public PCursor<Command*>
     
     int bars;
     
-    Input_cursor(PCursor<Command*>);
+    Input_cursor(PCursor<Input_command*>);
     /// hmm. not safe. Should rethink cursor.
     void operator++(int);
     /** warning: no optor -- () defined.. */
     void reset();
     Real when()const;
-    void add(Command*);
+    void add(Input_command*);
     void setpartial(Real);
-    void addbot(Command*);
+    void addbot(Input_command*);
     void sync();
     void print()const;   
     void last_command_here();
 };
 
 /// the list of commands in Score
-struct Input_commands : public IPointerList<Command*> {
+struct Input_commands : public IPointerList<Input_command*> {
     Input_cursor ptr;
 
     /****************/
@@ -50,7 +51,7 @@ struct Input_commands : public IPointerList<Command*> {
     
     Input_commands();
     Input_commands(Input_commands const&);
-    void add(Command*);
+    void add(Input_command);
     void reset();
     void print()const;
     Staff_commands *parse() const;
@@ -58,7 +59,7 @@ struct Input_commands : public IPointerList<Command*> {
 
 
 void
-interpret_meter(Command *c, int &beats_per_meas, int& one_beat,
+interpret_meter(Input_command *c, int &beats_per_meas, int& one_beat,
                Real& whole_per_measure);
 #endif // INPUTCOMMANDS_HH
 
diff --git a/hdr/inputscore.hh b/hdr/inputscore.hh
new file mode 100644 (file)
index 0000000..a34e6d9
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef ISCORE_HH
+#define ISCORE_HH
+#include "vray.hh"
+#include "proto.hh"
+#include "plist.hh"
+
+
+/// the total music def of one movement
+struct Input_score {
+    /// paper_, staffs_ and commands_ form the problem definition.
+    Paperdef *paper_;
+    IPointerList<Input_staff*> staffs_;
+    IPointerList<Input_command*> commands_;
+    
+    /****************************************************************/
+    Input_score();
+    Input_score(Input_score&);
+    void add(svec<Input_command*> &s);
+    void add(Input_staff*);
+    ~Input_score();
+    /// construction
+    void set(Paperdef*);
+    void print() const;
+    Score*parse();
+};
+/**
+        
+    */
+#endif
diff --git a/src/inputscore.cc b/src/inputscore.cc
new file mode 100644 (file)
index 0000000..89ec2bd
--- /dev/null
@@ -0,0 +1,61 @@
+#include "debug.hh"
+#include "inputcommand.hh"
+#include "inputscore.hh"
+#include "inputstaff.hh"
+#include "score.hh"
+#include "paper.hh"
+
+void
+Input_score::add(svec<Input_command*> &s)
+{
+    commands_.bottom().add(get_reset_command());
+    for (int i=0; i < s.sz(); i++)
+       commands_.bottom().add(s[i]);
+}
+
+void
+Input_score::add(Input_staff*s)
+{
+    staffs_.bottom().add(s);
+}
+
+void
+Input_score::set(Paperdef*p)
+{
+    delete paper_;
+    paper_ = p;
+}
+
+Score*
+Input_score::parse()
+{
+    Paperdef* p=new Paperdef(*paper_);
+    Score *s = new Score(p);
+    
+    for (PCursor<Input_staff*> i(staffs_); i.ok(); i++) {
+       Staff* staf=i->parse(commands_);
+       s->add(staf);
+    }
+    return s;
+}
+
+Input_score::~Input_score()
+{
+    // should fix paper/symtabs to allow this deletion.
+//    delete paper_;
+}
+
+Input_score::Input_score()
+{
+    paper_=new Paperdef;
+}
+
+void
+Input_score::print()const
+{
+    mtor << "Input_score {\n";
+    for (PCursor<Input_staff*> i(staffs_); i.ok(); i++) {
+       i->print();
+    }
+    mtor << "}\n";
+}
diff --git a/src/inputstaff.cc b/src/inputstaff.cc
new file mode 100644 (file)
index 0000000..2337f6a
--- /dev/null
@@ -0,0 +1,79 @@
+#include "getcommand.hh"
+#include "debug.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"
+
+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)
+{
+    type= s;
+}
+
+void
+Input_staff::add(Horizontal_music*m)
+{
+    music_.bottom().add(m);
+}
+
+Staff*
+Input_staff::parse(PointerList<Input_command*> score_wide)
+{
+    Staff *p=0;
+    
+    if (type == "melodic")
+       p = new Melodic_staff;
+    else if (type == "rhythmic")
+       p = new Rhythmic_staff;
+
+    for (PCursor<Horizontal_music*> i(music_); i.ok(); i++) {
+       Voice_list vl = i->convert();
+       p->add(vl);
+    }
+
+    Input_commands commands;
+    for (PCursor<Input_command*> i(score_wide); i.ok(); i++) 
+       commands.add(**i);
+    for (PCursor<Input_command*> i(commands_); i.ok(); i++) 
+       commands.add(**i);
+
+    p->staff_commands_ = commands.parse();
+
+    return p;
+}
+
+Input_staff::Input_staff(Input_staff&s)
+{
+    for (PCursor<Input_command*> i(s.commands_); i.ok(); i++)
+       commands_.bottom().add(new Input_command(**i));
+    for (PCursor<Horizontal_music*> i(s.music_); i.ok(); i++)
+       add(i);
+
+    type = s.type;
+}
+
+void
+Input_staff::print() const
+{
+#ifndef NPRINT
+    mtor << "Input_staff {\n";
+    for (PCursor<Input_command*> i(commands_); i.ok(); i++)
+       i->print();
+    for (PCursor<Horizontal_music*> i(music_); i.ok(); i++)
+       i->print();
+    mtor << "}\n";
+#endif
+}
index 80921422faf386aa7c3bfb01305be9c788a92d32..d9c85526d7786c706506e950206e79aa1bcecffa 100644 (file)
@@ -1,4 +1,8 @@
 #include "command.hh"
+#include "inputscore.hh"
+#include "inputstaff.hh"
+#include "inputmusic.hh"
+#include "inputcommand.hh"
 #include "molecule.hh"
 #include "plist.cc"