]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/completion-note-heads-engraver.cc
Issue 4550 (2/2) Avoid "using namespace std;" in included files
[lilypond.git] / lily / completion-note-heads-engraver.cc
index bddca70abbd3faa3175969eaa769363e067c6ec5..27d950b690ecbd4f8aff608bc0f3aa33946df4aa 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 1997--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -18,7 +18,6 @@
 */
 
 #include <cctype>
-using namespace std;
 
 #include "dot-column.hh"
 #include "dots.hh"
@@ -39,6 +38,8 @@ using namespace std;
 
 #include "translator.icc"
 
+using std::vector;
+
 /*
   How does this work?
 
@@ -59,7 +60,7 @@ class Completion_heads_engraver : public Engraver
   vector<Item *> notes_;
   vector<Item *> prev_notes_;
   // Must remember notes for explicit ties.
-  vector<Grob *> ties_;
+  vector<Spanner *> ties_;
   vector<Stream_event *> note_events_;
   Spanner *tie_column_;
   Moment note_end_mom_;
@@ -99,7 +100,7 @@ Completion_heads_engraver::listen_note (Stream_event *ev)
   Moment now = now_mom ();
   Moment musiclen = get_event_length (ev, now);
 
-  note_end_mom_ = max (note_end_mom_, (now + musiclen));
+  note_end_mom_ = std::max (note_end_mom_, (now + musiclen));
   do_nothing_until_ = Rational (0, 0);
 }
 
@@ -109,15 +110,21 @@ Completion_heads_engraver::listen_note (Stream_event *ev)
 Moment
 Completion_heads_engraver::next_moment (Rational const &note_len)
 {
-  Moment *e = unsmob_moment (get_property ("measurePosition"));
-  Moment *l = unsmob_moment (get_property ("measureLength"));
+  Moment *e = unsmob<Moment> (get_property ("measurePosition"));
+  Moment *l = unsmob<Moment> (get_property ("measureLength"));
   if (!e || !l || !to_boolean (get_property ("timing")))
     {
       return Moment (0, 0);
     }
 
   Moment result = *l - *e;
-  Moment const *unit = unsmob_moment (get_property ("completionUnit"));
+  if (result < 0)
+    {
+      programming_error ("invalid measure position: "
+                         + e->to_string () + " of " + l->to_string ());
+      return 0;
+    }
+  Moment const *unit = unsmob<Moment> (get_property ("completionUnit"));
 
   if (unit)
     {
@@ -156,7 +163,7 @@ Item *
 Completion_heads_engraver::make_note_head (Stream_event *ev)
 {
   Item *note = make_item ("NoteHead", ev->self_scm ());
-  Pitch *pit = unsmob_pitch (ev->get_property ("pitch"));
+  Pitch *pit = unsmob<Pitch> (ev->get_property ("pitch"));
 
   int pos = pit->steps ();
   SCM c0 = get_property ("middleCPosition");
@@ -192,7 +199,7 @@ Completion_heads_engraver::process_music ()
     }
   else
     {
-      orig = unsmob_duration (note_events_[0]->get_property ("duration"));
+      orig = unsmob<Duration> (note_events_[0]->get_property ("duration"));
       note_dur = *orig;
       SCM factor = get_property ("completionFactor");
       if (ly_is_procedure (factor))
@@ -265,7 +272,7 @@ Completion_heads_engraver::process_music ()
 void
 Completion_heads_engraver::make_tie (Grob *left, Grob *right)
 {
-  Grob *p = make_spanner ("Tie", SCM_EOL);
+  Spanner *p = make_spanner ("Tie", SCM_EOL);
   Tie::set_head (p, LEFT, left);
   Tie::set_head (p, RIGHT, right);
   announce_end_grob (p, SCM_EOL);