Trim include dependency graph, especially for io.h and session.h.
[ardour.git] / libs / ardour / ardour / buffer_set.h
index dfb5dd361107cc161c21b4e8883b17fc905ee5f4..3f7a6e7665b6db7f0a561ea7125dc3514c0f7272 100644 (file)
 #include <vector>
 #include <ardour/chan_count.h>
 #include <ardour/data_type.h>
+#include <ardour/types.h>
 
 namespace ARDOUR {
 
 class Buffer;
 class AudioBuffer;
+class MidiBuffer;
 class PortSet;
 
 
@@ -52,7 +54,7 @@ public:
 
        void clear();
        
-       void attach_buffers(PortSet& ports);
+       void attach_buffers(PortSet& ports, nframes_t nframes, nframes_t offset);
 
        void ensure_buffers(const ChanCount& count, size_t buffer_capacity);
        void ensure_buffers(DataType type, size_t num_buffers, size_t buffer_capacity);
@@ -70,19 +72,21 @@ public:
        Buffer& get(DataType type, size_t i)
        {
                assert(i <= _count.get(type));
-               return *_buffers[type.to_index()][i];
+               return *_buffers[type][i];
        }
 
        AudioBuffer& get_audio(size_t i)
        {
                return (AudioBuffer&)get(DataType::AUDIO, i);
        }
-
-       void read_from(BufferSet& in, jack_nframes_t nframes, jack_nframes_t offset=0)
+       
+       MidiBuffer& get_midi(size_t i)
        {
-               throw; // FIXME: implement this with spiffy DataType iterator etc.
+               return (MidiBuffer&)get(DataType::MIDI, i);
        }
 
+       void read_from(BufferSet& in, jack_nframes_t nframes, jack_nframes_t offset=0);
+
        // ITERATORS
        
        // FIXME: this is a filthy copy-and-paste mess
@@ -107,7 +111,7 @@ public:
        };
 
        audio_iterator audio_begin() { return audio_iterator(*this, 0); }
-       audio_iterator audio_end()   { return audio_iterator(*this, _count.get(DataType::AUDIO)); }
+       audio_iterator audio_end()   { return audio_iterator(*this, _count.n_audio()); }
 
        class iterator {
        public:
@@ -117,6 +121,7 @@ public:
                iterator& operator++() { ++_index; return *this; } // yes, prefix only
                bool operator==(const iterator& other) { return (_index == other._index); }
                bool operator!=(const iterator& other) { return (_index != other._index); }
+               iterator operator=(const iterator& other) { _set = other._set; _type = other._type; _index = other._index; return *this; }
 
        private:
                friend class BufferSet;
@@ -136,7 +141,7 @@ public:
 private:
        typedef std::vector<Buffer*> BufferVec;
 
-       /// Vector of vectors, indexed by DataType::to_index()
+       /// Vector of vectors, indexed by DataType
        std::vector<BufferVec> _buffers;
 
        /// Use counts (there may be more actual buffers than this)
@@ -145,7 +150,7 @@ private:
        /// Available counts (number of buffers actually allocated)
        ChanCount _available;
 
-       /// Whether we (don't) 'own' the contained buffers (are a mirror of a PortSet)
+       /// Whether we (don't) 'own' the contained buffers (otherwise we mirror a PortSet)
        bool _is_mirror;
 };