+++ /dev/null
-// cursor.hh
-
-#ifndef __CURSOR_HH
-#define __CURSOR_HH
-
-#include "link.hh"
-template<class T> class List;
-
-/** iterator to List.
- add and insert extend the list
- items are always stored as copies in List, but:
- List<String> : copies of String stored
- List<String*> : copies of String* stored!
-
- the operations add and insert actually delegate the work to List class.
- */
-template<class T>
-class Cursor
-{
-public:
- /** create cursor, set at top. The const part isn't true, actually, #list#
- surely isn't const, but I get tired of the warning messages. */
- Cursor (const List<T>& list, Link<T>* pointer = 0);
- Cursor (const Cursor<T>& cursor);
-
- T& thing();
-
- /// return current T
- T& operator *() { return thing(); }
- operator T() { return thing(); }
- Cursor<T> operator =(const Cursor<T>& c);
-
- /// make cursor with #no# items back
- Cursor<T> operator -(int no) const;
-
- /// make cursor with #no# items further
- Cursor<T> operator +(int no) const;
- int operator -(Cursor<T> op) const;
- Cursor<T> operator -=(int);
- Cursor<T> operator +=(int);
- /// move one down
- void next();
- /// move one up.
- void previous();
- /// return current and move one down
- Cursor<T> operator ++(int);
-
- /// return current and move one up
- Cursor<T> operator --(int);
-
- /// point to link?
- bool ok() const;
-
- /// ++ items left?
- bool forward() const;
-
- /// -- items left?
- bool backward() const;
-
- /** put (copy) after me in List.
- analogously to editor. ok() interpreted as at end
- of line.
-
- PRE: !ok, POST: added to bottom()
-
- PRE: ok, POST: added after me
-
- cursor points to same object, cursor.next() is newly added
- object.
- */
- void add (T const & thing);
-
- /** put (copy) before me in List.
- analogously to editor. ok() interpreted as at begin of
- line.
-
- PRE: !ok, POST: add to top()
-
- PRE: ok, POST: add before me
-
- cursor points to same object, cursor.previous()
- is newly inserted object.
- */
-
- void insert (T const & thing);
- ///
- void backspace();
-
- ///
- void del();
-
- /// access the list this came from
- List<T>* list_l() const ;
- Link<T>* pointer();
- static int compare (Cursor<T> a,Cursor<T>b) { return a-b; }
-
-private:
-
- Link<T>* pointer_;
- List<T>* list_l_;
-};
-
-
-/*
- comparisons.
- */
-#include "compare.hh"
-
-
-TEMPLATE_INSTANTIATE_COMPARE(Cursor<T>, Cursor<T>::compare, template<class T>);
-
-#include "pcursor.hh"
-#include "list.hh"
-#include "cursor.icc"
-#include "iterate.hh"
-
-#endif // CURSOR_HH
+++ /dev/null
-/*
- cursor.icc -- implement Cursor
-
- source file of the Flower Library
-
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- Jan Nieuwenhuizen <janneke@gnu.org>
-*/
-
-
-#ifndef CURSOR_ICC
-#define CURSOR_ICC
-
-
-
-#include <assert.h>
-
-/**
- Initialisation of Cursor.. Set pointer and list fields.
- */
-template<class T>
-inline
-Cursor<T>::Cursor (const List<T> & list, Link<T>* p )
-{
- list_l_ = (List<T> *) &list; // damn const
- if (list.size())
- pointer_ = p ? p : list.top_;
- else
- pointer_ = p;
-}
-
-
-
-template<class T>
-inline
-Cursor<T>::Cursor (const Cursor<T>& cursor)
-{
- list_l_= cursor.list_l_;
- pointer_ = cursor.pointer_;
-}
-
-template<class T>
-inline T&
-Cursor<T>::thing()
-{
- assert (pointer_);
- return pointer_->thing();
-}
-
-template<class T>
-Cursor<T>
-Cursor<T>::operator =(const Cursor<T>& c)
-{
- assert (list_l_ == c.list_l_);
- pointer_ = c.pointer_;
- return *this;
-}
-
-template<class T>
-inline void
-Cursor<T>::add (const T& th)
-{
- list_l_->add (th, *this);
-}
-
-template<class T>
-inline void
-Cursor<T>::insert (const T& th)
-{
- list_l_->insert (th, *this);
-}
-
-template<class T>
-inline List<T> *
-Cursor<T>::list_l() const
-{
- return list_l_; // ugh!
-}
-
-template<class T>
-inline Link<T>*
-Cursor<T>::pointer()
-{
- return pointer_;
-}
-
-template<class T>
-inline bool
-Cursor<T>::backward() const
-{
- return (pointer_ != 0);
-}
-
-template<class T>
-inline bool
-Cursor<T>::forward() const
-{
- return (pointer_ != 0);
-}
-
-template<class T>
-inline bool
-Cursor<T>::ok() const
-{
- return (pointer_ != 0);
-}
-template<class T>
-inline void
-Cursor<T>::next()
-{
- assert (pointer_);
- pointer_ = pointer_->next();
-}
-
-template<class T>
-inline Cursor<T>
-Cursor<T>::operator ++(int)
-{
- Cursor<T> r (*this);
- next();
- return r;
-}
-
-template<class T>
-inline void
-Cursor<T>::previous()
-{
- assert (pointer_);
- pointer_ = pointer_->previous();
-}
-
-template<class T>
-inline Cursor<T>
-Cursor<T>::operator --(int)
-{
- Cursor<T> r (*this);
- previous();
- return r;
-}
-
-
-#endif // CURSOR_ICC
+++ /dev/null
-#ifndef CURSOR_CC
-#define CURSOR_CC
-
-#include "cursor.hh"
-#include <assert.h>
-
-template<class T>
-void
-Cursor<T>::backspace()
-{
- Cursor<T> c (*this);
- if (c.ok())
- c--;
- list_l_->remove (*this);
-}
-
-template<class T>
-void
-Cursor<T>::del()
-{
- Cursor<T> c (*this);
- if (c.ok())
- c++;
- list_l_->remove (*this);
- *this = c;
-}
-
-
-template<class T>
-Cursor<T>
-Cursor<T>::operator -=(int j)
-{
- while (j--)
- (*this)--;
- return *this;
-}
-template<class T>
-Cursor<T>
-Cursor<T>::operator +=(int j)
-{
- while (j++)
- (*this)++;
- return *this;
-}
-
-template<class T>
-Cursor<T>
-Cursor<T>::operator +(int i) const
-{
- Cursor<T> r = *this;
-
- if (i<0)
- return r -(-i);
-
- while (i--)
- r++;
-
- return r;
-}
-
-template<class T>
-Cursor<T>
-Cursor<T>::operator -(int i) const
-{
- Cursor<T> r = *this;
- if (i<0)
- return r +(-i);
-
- while (i--)
- r--;
-
- return r;
-}
-/*
- warning: can't use Cursor::operator == (Cursor),
- since it uses Cursor::operator-(Cursor)
- */
-template<class T>
-int
-Cursor<T>::operator-(Cursor<T> rhs) const
-{
- assert (rhs.list_l_ == list_l_);
- int dif = 0;
-
- // search from *this on further up (positive difference)
- Cursor<T> c (*this);
- while (c.ok() && c.pointer_ != rhs.pointer_)
- {
- c--;
- dif++;
- }
-
- if (c.ok())
- goto gotcha; // so, sue me.
-
- // search in direction of bottom. (negative diff)
- dif =0;
- c=*this;
- while (c.ok() && c.pointer_ !=rhs.pointer_)
- {
- dif --;
- c++;
- }
- assert (c.ok());
-
- gotcha:
- assert ((*this - dif).pointer_ == c.pointer_);
- return dif;
-}
-
-#endif
+++ /dev/null
-// link.hh
-
-#ifndef __LINK_HH
-#define __LINK_HH
-template<class T>
-class List;
-
-
-/// class for List
-template<class T>
-class Link
-{
-// friend class Cursor<T>;
-public:
- Link (T const & thing);
-
- Link<T>* previous();
- Link<T>* next();
-
- /// put new Link item after me in list
- void add (T const & thing);
- /// put new Link item before me in list
- void insert (T const & thing);
- void remove (List<T> &l);
-
- T& thing();
- void OK() const;
-private:
- Link (Link<T>* previous, Link<T>* next, T const & thing);
-
- T thing_;
- Link<T>* previous_;
- Link<T>* next_;
-};
-
-#include "link.icc"
-
-#endif // __LINK_HH //
+++ /dev/null
-// link.inl -*-c++-*-
-#ifndef LINK_INL
-#define LINK_INL
-#include <assert.h>
-template<class T>
-inline
-void
-Link<T>::OK() const
-{
-#ifndef NDEBUG
- if (previous_)
- {
- assert (previous_->next_ == this);
- }
- if (next_)
- {
- assert (next_->previous_ == this);
- }
-#endif
-}
-
-template<class T>
-inline
-Link<T>::Link (const T& thing) :
- thing_(thing)
-{
- previous_ = next_ = 0;
-}
-
-template<class T>
-inline
-Link<T>::Link (Link<T>* previous, Link<T>* next, const T& thing) :
- thing_(thing)
-{
- previous_ = previous;
- next_ = next;
-}
-
-template<class T>
-inline
-Link<T>*
-Link<T>::next()
-{
- return next_;
-}
-
-template<class T>
-inline
-Link<T>*
-Link<T>::previous()
-{
- return previous_;
-}
-
-template<class T>
-inline
-void
-Link<T>::add (const T& thing)
-{
-
- Link<T>* l = new Link<T>(this, next_, thing);
- if (next_)
- next_->previous_ = l;
- next_ = l;
-}
-
-template<class T>
-inline void
-Link<T>::insert (const T& thing)
-{
- // Link<T>* l = new Link<T>(next_, this, thing);
- // bugfix hwn 16/9/96
- Link<T>* l = new Link<T>(previous_, this, thing);
- if (previous_)
- previous_->next_ = l;
- previous_ = l;
-}
-
-/*
- don't forget to adjust #l#'s top_ and bottom_.
- */
-template<class T>
-inline void
-Link<T>::remove (List<T> &l)
-{
- if (previous_)
- previous_->next_ = next_;
- else
- l.top_ = next_;
-
- if (next_)
- next_->previous_ = previous_;
- else
- l.bottom_ = previous_;
-}
-
-template<class T>
-inline
-T&
-Link<T>::thing()
-{
- return thing_;
-}
-#endif
+++ /dev/null
-#ifndef __LIST_HH
-#define __LIST_HH
-
-class ostream;
-template<class T> class Cursor;
-template<class T> class Link;
-
-/** all-purpose doubly linked list.
-
- List can be seen as all items written down on paper,
- from top to bottom
-
- class Cursor is used to extend List
-
- items are always stored as copies in List, but:
- #List<String># : copies of #String# stored
- #List<String*># : copies of #String*# stored!
- (do not use, use \Ref{Link_list} #<String*># instead.)
-
- {\bf note:}
- retrieving "invalid" cursors, i.e.
- #top()/bottom ()# from empty list, #find ()# without success,
- results in a nonvalid Cursor (#!ok()#)
-
-
- INVARIANTEN!
-*/
-
-template<class T>
-class List
-{
-public:
- List (List const&src);
-
- /// construct empty list
- List();
- virtual ~List();
-
- int size() const;
-
- Cursor<T> bottom() const; // const sucks.
- Cursor<T> top() const;
-
- void OK() const; // check list
- void junk_links();
-
-protected:
- friend class Cursor<T>;
- friend class Link<T>;
-
- void concatenate (List<T> const &s);
-
- /** make *this empty.
-
- POST:
- size == 0
-
- WARNING:
- contents lost, and not deleted.
- */
- void set_empty();
-
- void add (T const & thing, Cursor<T> &after_me);
-
- /// put thing before #before_me#
- void insert (T const & thing, Cursor<T> &before_me);
-
- /** Remove link pointed to by me. Destructor of contents called
- (nop for pointers)
-
- POST
- none;
-
-
- WARNING: do not use #me# after calling
- */
- void remove (Cursor<T> me);
-
-
- /* ************** */
-
- int size_;
- Link<T>* top_;
- Link<T>* bottom_;
-};
-
-#include "list.icc"
-#include "cursor.hh"
-
-#endif // __LIST_HH //
-
-
-
-
+++ /dev/null
-/*
- list.icc -- implement List inline functions
-
- source file of the Flower Library
-
- (c) 1996, 1997--1999
- Jan Nieuwenhuizen <janneke@gnu.org>
- Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#ifndef LIST_ICC
-#define LIST_ICC
-
-template<class T>
-inline
-List<T>::List()
-{
- set_empty();
-}
-
-template<class T>
-inline void
-List<T>::set_empty()
-{
- top_ = bottom_ = 0;
- size_ = 0;
-}
-
-template<class T>
-inline void
-List<T>::remove (Cursor<T> me)
-{
- if (me.ok())
- {
- Link<T> *lp = me.pointer();
- lp->remove (*this);
- delete lp;
- size_--;
- }
-}
-
-template<class T>
-inline int
-List<T>::size() const
-{
- return size_;
-}
-
-template<class T>
-inline Cursor<T>
-List<T>::top() const
-{
- return Cursor<T>(*this, top_);
-}
-
-
-template<class T>
-inline Cursor<T>
-List<T>::bottom() const
-{
- return Cursor<T>(*this, bottom_);
-}
-
-
-#endif
-
+++ /dev/null
-/*
- list.tcc -- implement List<T>
-
- source file of the Flower Library
-
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-#ifndef LIST_CC
-#define LIST_CC
-
-
-#include "list.hh"
-
-template<class T>
-List<T>::List (List const&src)
-{
- set_empty();
- // probably el stupido
- for (Cursor<T> c (src); c.ok(); c++)
- bottom().add (c);
-}
-
-template<class T>
-void
-List<T>::OK() const
-{
- int i = size_;
- Link<T> *lp = top_;
- while (i--)
- {
- assert (lp);
- lp->OK();
- lp = lp->next();
- }
- assert (!lp);
- i = size_;
- lp = bottom_;
- while (i--)
- {
- assert (lp);
- lp->OK();
- lp = lp->previous();
- }
- assert (!lp);
-}
-
-template<class T>
-void
-List<T>::junk_links()
-{
- Cursor<T> c (*this);
- while (c.ok())
- c.del();
-}
-
-template<class T>
-List<T>::~List()
-{
- junk_links();
-}
-
-/**
-
- add after after_me.
-
- Procedure:
- \begin{itemize}
- \item if #after_me# is #ok()#, add after #after_me#, else
- \item if list !empty simply add to bottom, else
- \item list is empty: create first \Ref{Link} and initialize
- #bottom_# and #top_#.
- \end{itemize}
-*/
-template<class T>
-void
-List<T>::add (T const & thing, Cursor<T> &after_me)
-{
- if (!size_) { // not much choice if list is empty
- bottom_ = top_ = new Link<T>(thing);
- if (!after_me.ok())
- after_me = bottom();
- }
- else { // add at aprioprate place
- if (!after_me.ok())
- after_me = bottom();
- Link<T> *p =after_me.pointer();
- p->add (thing);
- if (p == bottom_) // adjust bottom_ if necessary.
- bottom_ = p->next();
- }
-
- size_++;
-}
-
-template<class T>
-void
-List<T>::insert (T const & thing, Cursor<T> &before_me)
-{
- if (!size_)
- {
- bottom_ = top_ = new Link<T>(thing);
- if (!before_me.ok())
- before_me = top();
-
- }
- else
- {
- if (!before_me.ok())
- before_me = top();
-
- Link<T> *p = before_me.pointer() ;
-
- p->insert (thing);
- if (p == top_)
- top_ = p->previous();
- }
-
- size_++;
-}
-
-
-template<class T>
-void
-List<T>::concatenate (List<T> const&s)
-{
- Cursor<T> b (bottom());
- for (Cursor<T> c (s); c.ok(); c++)
- {
- b.add (c);
- b++;
- }
-}
-
-#ifndef __CYGWIN32__ // ugh should check for some gcc/egcs version
-
-// instantiate a template: explicit instantiation.
-#define LIST_INSTANTIATE(a) template class List<a>; \
- template class Cursor<a>; template class Link<a>
-
-#else
-
-#define LIST_INSTANTIATE(T)\
- static void force_list_members ()\
- {\
- List<T> bla;\
- bla.top().add ((void*)0);\
- }
-#endif
-
-#endif
-
+++ /dev/null
-/*
- pcursor.hh -- part of flowerlib
-
- (c) 1996 Han-Wen Nienhuys&Jan Nieuwenhuizen
-*/
-
-#ifndef PCURSOR_HH
-#define PCURSOR_HH
-
-#include "plist.hh"
-#include "cursor.hh"
-
-/** cursor to go with Link_list.
- don't create Link_list<void*>'s.
- This cursor is just an interface class for Cursor. It takes care of the
- appropriate type casts
- */
-template<class T>
-class PCursor : private Cursor<void *> {
- friend class Pointer_list<T>;
-
- /// delete contents
- void junk();
-public:
- Cursor<void*>::ok;
- Cursor<void*>::del;
- Cursor<void*>::backspace;
- Cursor<void*>::next;
- Cursor<void*>::previous;
-
- T remove_p() {
- T p = ptr();
- Cursor<void*>::del();
- return p;
- }
- T remove_prev_p() {
- assert (ok());
- (*this)--;
- return remove_p();
- }
-
- Link_list<T> *list_l() { return (Link_list<T> *)Cursor<void*>::list_l (); }
- PCursor<T> operator++(int) { return Cursor<void*>::operator++(0);}
- PCursor<T> operator--(int) { return Cursor<void*>::operator--(0); }
- PCursor<T> operator+=(int i) { return Cursor<void*>::operator+=(i);}
- PCursor<T> operator-=(int i) { return Cursor<void*>::operator-=(i); }
- PCursor<T> operator -(int no) const { return Cursor<void*>::operator-(no);}
- int operator -(PCursor<T> op) const { return Cursor<void*>::operator-(op);}
- PCursor<T> operator +(int no) const {return Cursor<void*>::operator+(no);}
- PCursor (const Link_list<T> & l) : Cursor<void*> (l) {}
- PCursor (const Cursor<void*>& cursor) : Cursor<void*>(cursor) { }
- void* vptr() const { return *((Cursor<void*> &) *this); }
-
- // should return T& ?
- T ptr() const { return (T) vptr (); }
- T operator ->() const { return ptr(); }
- operator T() { return ptr(); }
- T operator *() { return ptr(); }
- void add (T const & p) { Cursor<void*>::add ((void*) p); }
- void insert (T const & p) { Cursor<void*>::insert ((void*) p);}
- static int compare (PCursor<T> a,PCursor<T>b) {
- return Cursor<void*>::compare (a,b);
- }
-};
-
-
-
-#include "compare.hh"
-TEMPLATE_INSTANTIATE_COMPARE(PCursor<T>, PCursor<T>::compare, template<class T>);
-
-#endif
+++ /dev/null
-#include "pcursor.hh"
-
-template<class T>
-void
-PCursor<T>::junk()
-{
-#if !defined (NDEBUG) && defined (PARANOID)
- list_l()->OK();
-#endif
-
- delete ptr();
-#if !defined (NDEBUG)&&defined (PARANOID)
- thing() = 0;
- list_l()->OK();
-#endif
-}
+++ /dev/null
-/*
- list.hh -- part of flowerlib
-
- (c) 1996 Han-Wen Nienhuys & Jan Nieuwenhuizen
-*/
-
-#ifndef PLIST_HH
-#define PLIST_HH
-
-#include "list.hh"
-
-/**
- A list of pointers.
-
- Use for list of pointers, e.g. Link_list<AbstractType*>.
- This class does no deletion of the pointers, but it knows how to
- copy itself (shallow copy). We could have derived it from List<T>,
- but this design saves a lot of code dup; for all Link_lists in the
- program only one parent List<void*> is instantiated.
- */
-template<class T>
-class Link_list : public List<void *>
-{
-public:
- PCursor<T> top() const{
- return PCursor<T> (List<void*>::top());
- }
- PCursor<T> bottom() const {
- return PCursor<T> (List<void*>::bottom());
- }
- PCursor<T> find (T) const;
- void concatenate (Link_list<T> const &s) { List<void*>::concatenate (s); }
-
- Link_list() {}
-};
-
-/**
-
- Link_list which deletes pointers given to it.
-
- NOTE:
-
- The copy constructor doesn't do what you'd want:
- Since T might have a virtual ctor, we don't try to do a
-
- new T(**cursor)
-
- You have to copy this yourself, or use the macro Link_list__copy
-
- TODO
- operator =()
- */
-template<class T>
-class Pointer_list : public Link_list<T> {
-
-public:
- void junk();
- Pointer_list (Pointer_list const& l) : Link_list<T> (l) { set_empty(); }
- Pointer_list() { }
- ~Pointer_list() { junk (); }
-};
-
-#define Pointer_list__copy(T, to, from, op) \
-for (PCursor<T> _pc_(from); _pc_.ok(); _pc_++)\
-to.bottom().add (_pc_->op)\
-\
-
-
-template<class T>
-void PL_copy (Pointer_list<T*> &dst,Pointer_list<T*> const&src);
-
-
-
-#include "plist.icc"
-
-#endif
+++ /dev/null
-/* -*-c++-*-
- plist.icc -- part of flowerlib
-
- (c) 1996, 1997--1999 Han-Wen Nienhuys& Jan Nieuwenhuizen
-*/
-
-#ifndef PLIST_INL
-#define PLIST_INL
-
-template<class T>
-inline void
-PL_copy (Pointer_list<T*> &to, Pointer_list<T*> const&src)
-{
- for (PCursor<T*> pc (src); pc.ok(); pc++)
- {
- T *q = pc;
- T *p=new T(*q) ;
- to.bottom().add (p);
- }
-}
-
-
-template<class T>
-inline PCursor<T>
-Link_list<T>::find (T what) const
-{
- PCursor<T> i (*this);
- for (; i.ok(); i++)
- if (i.ptr() == what)
- break;
- return i;
-}
-#endif
+++ /dev/null
-/*
- plist.tcc -- implement Pointer_list
-
- source file of the Flower Library
-
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#ifndef PLIST_TCC
-#define PLIST_TCC
-
-#include "plist.hh"
-
-template<class T>
-void
-Pointer_list<T>::junk()
-{
- PCursor<T> c (*this);
- while (c.ok())
- {
- delete c.remove_p();
- }
-}
-
-#ifndef __CYGWIN32__ // ugh should check for some gcc/egcs version
-
-#define POINTERLIST_INSTANTIATE(a) template class Pointer_list<a*>;\
- template class PCursor<a*>;
-
-#else
-
-#define POINTERLIST_INSTANTIATE(T)\
- static void force_junk##T ()\
- {\
- Pointer_list<T*> bla;\
- bla.junk ();\
- }
-
-#endif
-
-#endif // PLIST_TCC
+++ /dev/null
-< \context Staff = VA {
- \property Staff.staffLineLeading = "4" \property Staff.fontsize = "-2"
- \property Voice . dynamicDir = \up \stemdown
-\key gis;
- c8 d [e f g a] b c \ff
- }
-
-\context Staff = VB { \property Voice . dynamicDir = \down c,,4 \ff}
-
->
-
-\version "1.0.16";
+++ /dev/null
-/*
- repeated-music-iterator.hh -- declare Repeated_music_iterator
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1998--1999 Jan Nieuwenhuizen <janneke@gnu.org>
-
- */
-
-#ifndef REPEATED_MUSIC_ITERATOR_HH
-#define REPEATED_MUSIC_ITERATOR_HH
-
-#include "music-list-iterator.hh"
-
-class Repeated_music_iterator : public Music_list_iterator
-{
-public:
- Repeated_music_iterator ();
- virtual ~Repeated_music_iterator ();
-
- virtual void construct_children ();
- virtual Moment next_moment () const;
- virtual bool ok () const;
-
-protected:
- virtual void do_print () const;
- virtual void do_process_and_next (Moment);
-
-private:
- void start_next_element ();
-
- int unfold_i_;
- Moment here_mom_;
- Music_iterator* repeat_iter_p_;
- Music_list_iterator* alternative_iter_p_;
-};
-
-#endif /* REPEATED_MUSIC_ITERATOR_HH */
-
+++ /dev/null
-/*
- repeated-music.hh -- declare Repeated_music
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1998--1999 Jan Nieuwenhuizen <janneke@gnu.org>
-
- */
-
-#ifndef REPEATED_MUSIC_HH
-#define REPEATED_MUSIC_HH
-
-#include "music-list.hh"
-
-/**
- Repeats and voltas
- */
-class Repeated_music : public Music
-{
-public:
- int repeats_i_;
- bool unfold_b_;
- Music* repeat_p_;
- /*
- UGH FIXME: this should be:
-
- Music_list * alternative_p_;
- */
- Music_sequence* alternative_p_;
-
- Repeated_music (Music*, int n, Music_sequence*);
- Repeated_music (Repeated_music const& s);
- virtual ~Repeated_music ();
-
- virtual void do_print () const;
- virtual void transpose (Musical_pitch p);
- virtual Moment length_mom () const;
- virtual Musical_pitch to_relative_octave (Musical_pitch p);
- VIRTUAL_COPY_CONS(Music);
-};
-
-#endif /* REPEATED_MUSIC_HH */
-
+++ /dev/null
-/*
- repeated-music-iterator.cc -- implement Repeated_music_iterator
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1998--1999 Jan Nieuwenhuizen <janneke@gnu.org>
-
- */
-
-#include "repeated-music-iterator.hh"
-#include "repeated-music.hh"
-#include "musical-request.hh"
-#include "translator-group.hh"
-#include "command-request.hh"
-
-Repeated_music_iterator::Repeated_music_iterator ()
-{
- repeat_iter_p_ = 0;
- alternative_iter_p_ = 0;
- here_mom_ = 0;
- unfold_i_ = -1;
-}
-
-Repeated_music_iterator::~Repeated_music_iterator ()
-{
- delete repeat_iter_p_;
- delete alternative_iter_p_;
-}
-
-void
-Repeated_music_iterator::do_print () const
-{
- if (repeat_iter_p_) repeat_iter_p_->print ();
- if (alternative_iter_p_) alternative_iter_p_->print ();
-}
-
-void
-Repeated_music_iterator::construct_children ()
-{
- repeat_iter_p_ = get_iterator_p (dynamic_cast<Repeated_music const*> (music_l_)->repeat_p_);
-}
-
-void
-Repeated_music_iterator::do_process_and_next (Moment m)
-{
- if (first_b_)
- {
- bool success = report_to_l ()->try_music (dynamic_cast<Repeated_music const*> (music_l_));
- if (!success)
- music_l_->warning ( _("No one to print a volta bracket"));
- }
- if (repeat_iter_p_ && repeat_iter_p_->ok ())
- repeat_iter_p_->process_and_next (m - here_mom_);
- else
- alternative_iter_p_->process_and_next (m - here_mom_);
- Music_iterator::do_process_and_next (m);
-}
-
-Moment
-Repeated_music_iterator::next_moment () const
-{
-
- if (repeat_iter_p_)
- return repeat_iter_p_->next_moment () + here_mom_;
- else if (alternative_iter_p_)
- return alternative_iter_p_->next_moment () + here_mom_;
-
- Repeated_music const*r = dynamic_cast<Repeated_music const*>(music_l_);
- return r->alternative_p_->length_mom () + here_mom_;
-}
-
-/*
- FIXME
- */
-bool
-Repeated_music_iterator::ok () const
-{
- if (!repeat_iter_p_ && !alternative_iter_p_)
- return false;
-
- if ((repeat_iter_p_ && repeat_iter_p_->ok ())
- || (alternative_iter_p_ && alternative_iter_p_->ok ()))
- return true;
-
- Repeated_music_iterator *urg = (Repeated_music_iterator*)this;
- // urg, we're const
- urg->start_next_element ();
-
- return ok ();
-}
-
-
-void
-Repeated_music_iterator::start_next_element ()
-{
- Repeated_music const*rep =dynamic_cast<Repeated_music const*> (music_l_);
-
-
- if (repeat_iter_p_)
- {
- assert (!repeat_iter_p_->ok ());
- assert (!alternative_iter_p_);
- delete repeat_iter_p_;
- repeat_iter_p_ = 0;
- alternative_iter_p_ = dynamic_cast<Music_list_iterator*>
- (get_iterator_p ((Music*)rep->alternative_p_));
- here_mom_ += rep->repeat_p_->length_mom ();
- }
- else if (alternative_iter_p_)
- {
- assert (!alternative_iter_p_->ok ());
- assert (!repeat_iter_p_);
- delete alternative_iter_p_;
- alternative_iter_p_ = 0;
- if (unfold_i_ < 0)
- unfold_i_ = rep->unfold_b_ ?
- rep->repeats_i_ - 1 : 0;
- if (unfold_i_)
- {
- unfold_i_--;
- repeat_iter_p_ = get_iterator_p (rep->repeat_p_);
- // urg, assume same length alternatives for now...
-// here_mom_ += rep->alternative_p_->music_p_list_p_->top ()->length_mom ();
- /*
- URG
- this is *wrong* but at least it doesn't dump core
- when unfolding, the alternative (sequential) music
- shouldn't automatically move to the next alternative
-
- how to intercept this...
- */
- here_mom_ += rep->alternative_p_->length_mom ();
- }
- }
-}
-
+++ /dev/null
-/*
- repeated-music.cc -- implement Repeated_music
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1998--1999 Jan Nieuwenhuizen <janneke@gnu.org>
-
- */
-
-#include "repeated-music.hh"
-#include "musical-pitch.hh"
-
-Repeated_music::Repeated_music (Music* r, int n, Music_sequence* a)
-{
- repeats_i_ = n;
- unfold_b_ = false;
- repeat_p_ = r;
- alternative_p_ = a;
-}
-
-Repeated_music::~Repeated_music ()
-{
- delete repeat_p_;
- delete alternative_p_;
-}
-
-Repeated_music::Repeated_music (Repeated_music const& s)
- : Music (s)
-{
- repeats_i_ = s.repeats_i_;
- repeat_p_ = (s.repeat_p_) ? s.repeat_p_->clone () : 0;
- // urg?
- alternative_p_ = (s.alternative_p_) ? dynamic_cast <Music_sequence*> (s.alternative_p_->clone ()) : 0;
-}
-
-void
-Repeated_music::do_print () const
-{
- if (repeat_p_)
- repeat_p_->print ();
- if (alternative_p_)
- alternative_p_->print ();
-}
-
-void
-Repeated_music::transpose (Musical_pitch p)
-{
- if (repeat_p_)
- repeat_p_->transpose (p);
- if (alternative_p_)
- alternative_p_->transpose (p);
-}
-
-Moment
-Repeated_music::length_mom () const
-{
- Moment m;
- if (repeat_p_)
- m += repeat_p_->length_mom ();
- if (alternative_p_)
- m += alternative_p_->length_mom ();
- return m;
-}
-
-
-Musical_pitch
-Repeated_music::to_relative_octave (Musical_pitch p)
-{
- p = repeat_p_->to_relative_octave (p);
-
- p = alternative_p_->do_relative_octave (p, false);
- return p;
-
- /* ugh. Should
- \relative c'' \repeat 2 { c4 } { < ... > }
-
- and
-
- \relative c'' \repeat 2 { c4 }
- { { ...} }
-
- behave differently?
- */
-}