2 Copyright (C) 2008 Paul Davis
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __ardour_graph_h__
22 #define __ardour_graph_h__
24 #include <boost/shared_ptr.hpp>
26 #include <ardour/types.h>
35 GraphSink () : end_of_input (false) {}
36 virtual ~GraphSink () { end_of_input = false; }
38 // writes data and return number of frames written
39 virtual nframes_t write (T * data, nframes_t frames) = 0;
41 // Notifies end of input. All left over data must be written at this stage
42 virtual void set_end_of_input (bool state = true)
51 /// is a source for data
56 virtual ~GraphSource () {}
58 virtual nframes_t read (T * data, nframes_t frames) = 0;
61 /// Takes data in, processes it and passes it on to another sink
62 template <typename TIn, typename TOut>
63 class GraphSinkVertex : public GraphSink<TIn> {
66 virtual ~GraphSinkVertex () {}
68 void pipe_to (boost::shared_ptr<GraphSink<TOut> > dest) {
72 nframes_t write (TIn * data, nframes_t frames)
77 return process (data, frames);
80 virtual void set_end_of_input (bool state = true)
85 piped_to->set_end_of_input (state);
86 GraphSink<TIn>::end_of_input = state;
90 boost::shared_ptr<GraphSink<TOut> > piped_to;
92 /* process must process data,
93 use piped_to->write to write the data
94 and return number of frames written */
95 virtual nframes_t process (TIn * data, nframes_t frames) = 0;
100 #endif /* __ardour_graph_h__ */