diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 18:37:05 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 18:37:05 +0000 |
commit | 145364a8af6a1fec06556221e66d4b724a62fc9a (patch) | |
tree | 53bd71a544008c518034f208d64c932dc2883f50 /src/base/CompositionTimeSliceAdapter.h | |
download | rosegarden-145364a8af6a1fec06556221e66d4b724a62fc9a.tar.gz rosegarden-145364a8af6a1fec06556221e66d4b724a62fc9a.zip |
Added old abandoned KDE3 version of the RoseGarden MIDI tool
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/rosegarden@1097595 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/base/CompositionTimeSliceAdapter.h')
-rw-r--r-- | src/base/CompositionTimeSliceAdapter.h | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/src/base/CompositionTimeSliceAdapter.h b/src/base/CompositionTimeSliceAdapter.h new file mode 100644 index 0000000..01307e3 --- /dev/null +++ b/src/base/CompositionTimeSliceAdapter.h @@ -0,0 +1,149 @@ +// -*- c-basic-offset: 4 -*- + +/* + Rosegarden + A sequencer and musical notation editor. + + This program is Copyright 2000-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + This file is Copyright 2002 + Randall Farmer <[email protected]> + with additional work by Chris Cannam. + + The moral right of the authors to claim authorship of this work + has been asserted. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#ifndef _COMPOSITION_TIMESLICE_ADAPTER_H_ +#define _COMPOSITION_TIMESLICE_ADAPTER_H_ + +#include <list> +#include <utility> + +#include "Segment.h" + +namespace Rosegarden { + +class Event; +class Composition; +class SegmentSelection; + +/** + * CompositionTimeSliceAdapter provides the ability to iterate through + * all the events in a Composition in time order, across many segments + * at once. + * + * The CompositionTimeSliceAdapter is suitable for use as the backing + * container for the Set classes, notably GenericChord (see Sets.h). + * This combination enables you to iterate through a Composition as a + * sequence of chords composed of all Events on a set of Segments that + * lie within a particular quantize range of one another. + */ + +class CompositionTimeSliceAdapter +{ +public: + class iterator; + typedef std::set<TrackId> TrackSet; + + /** + * Construct a CompositionTimeSliceAdapter that operates on the + * given section in time of the given composition. If begin and + * end are equal, the whole composition will be used. + */ + CompositionTimeSliceAdapter(Composition* c, + timeT begin = 0, + timeT end = 0); + + /** + * Construct a CompositionTimeSliceAdapter that operates on the + * given section in time of the given set of segments within the + * given composition. If begin and end are equal, the whole + * duration of the composition will be used. + */ + CompositionTimeSliceAdapter(Composition* c, + SegmentSelection* s, + timeT begin = 0, + timeT end = 0); + + /** + * Construct a CompositionTimeSliceAdapter that operates on the + * given section in time of all the segments in the given set of + * tracks within the given composition. If begin and end are + * equal, the whole duration of the composition will be used. + */ + CompositionTimeSliceAdapter(Composition *c, + const TrackSet &trackIDs, + timeT begin = 0, + timeT end = 0); + + ~CompositionTimeSliceAdapter() { }; + + // bit sloppy -- we don't have a const_iterator + iterator begin() const; + iterator end() const; + + typedef std::vector<Segment *> segmentlist; + typedef std::vector<Segment::iterator> segmentitrlist; + + Composition *getComposition() { return m_composition; } + + class iterator { + friend class CompositionTimeSliceAdapter; + + public: + iterator() : + m_a(0), m_curEvent(0), m_curTrack(-1), m_needFill(true) { } + iterator(const CompositionTimeSliceAdapter *a) : + m_a(a), m_curEvent(0), m_curTrack(-1), m_needFill(true) { } + iterator(const iterator &); + iterator &operator=(const iterator &); + ~iterator() { }; + + iterator &operator++(); + iterator &operator--(); + + bool operator==(const iterator& other) const; + bool operator!=(const iterator& other) const; + + Event *operator*() const; + Event &operator->() const; + + int getTrack() const; + + private: + segmentitrlist m_segmentItrList; + const CompositionTimeSliceAdapter *m_a; + Event* m_curEvent; + int m_curTrack; + bool m_needFill; + + static bool strictLessThan(Event *, Event *); + }; + + +private: + friend class iterator; + + Composition* m_composition; + mutable iterator m_beginItr; + timeT m_begin; + timeT m_end; + + segmentlist m_segmentList; + + void fill(iterator &, bool atEnd) const; +}; + +} + +#endif |