00001 /* 00002 * @(#)Playable.h 3.00 20 May 1999 00003 * 00004 * Copyright (c) 2000 Pete Goodliffe (pete@cthree.org) 00005 * 00006 * This file is part of TSE3 - the Trax Sequencer Engine version 3.00. 00007 * 00008 * This library is modifiable/redistributable under the terms of the GNU 00009 * General Public License. 00010 * 00011 * You should have received a copy of the GNU General Public License along 00012 * with this program; see the file COPYING. If not, write to the Free Software 00013 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00014 * 00015 */ 00016 00017 #ifndef TSE3_PLAYABLE_H 00018 #define TSE3_PLAYABLE_H 00019 00020 #include "tse3/listen/Playable.h" 00021 00022 #include "tse3/Notifier.h" 00023 #include "tse3/Midi.h" 00024 00025 namespace TSE3 00026 { 00027 class PlayableIterator; 00028 00045 class Playable : public Notifier<PlayableListener> 00046 { 00047 public: 00048 00049 Playable() {} 00050 00051 virtual ~Playable() {}; 00052 00064 virtual PlayableIterator *iterator(Clock index) = 0; 00065 00074 virtual Clock lastClock() const = 0; 00075 00076 protected: 00077 00078 Playable &operator=(const Playable &); 00079 Playable(const Playable &); 00080 }; 00081 00097 class PlayableIterator 00098 { 00099 public: 00100 00113 PlayableIterator(); 00114 virtual ~PlayableIterator(); 00115 00122 const MidiEvent &operator*() const { return _next; } 00123 00130 const MidiEvent *operator->() const { return &_next; } 00131 00138 bool more() const { return _more; } 00139 00145 virtual void moveTo(Clock /*c*/) { _more = false; } 00146 00151 PlayableIterator &operator++(); 00152 00153 //PlayableIterator operator++(int); 00154 // We can't implement this operator: it is impossible to 00155 // make a copy of a PlayableIterator: there is no 00156 // copy constructor. 00157 00158 protected: 00159 00160 virtual void getNextEvent() = 0; 00161 00162 MidiEvent _next; // Implementations must put the next MidiEvent 00163 // in here. 00164 bool _more; // Implementations must define whether or not 00165 // this is true. 00166 private: 00167 00168 PlayableIterator &operator=(const PlayableIterator &); 00169 PlayableIterator(const PlayableIterator &); 00170 }; 00171 } 00172 00173 #endif