NOOP, remove trailing tabs/whitespace.
[ardour.git] / libs / audiographer / audiographer / utils / listed_source.h
1 #ifndef AUDIOGRAPHER_LISTED_SOURCE_H
2 #define AUDIOGRAPHER_LISTED_SOURCE_H
3
4 #include "audiographer/visibility.h"
5 #include "audiographer/types.h"
6 #include "audiographer/types.h"
7 #include "audiographer/source.h"
8
9 #include <list>
10
11 namespace AudioGrapher
12 {
13
14 /// An generic \a Source that uses a \a std::list for managing outputs
15 template<typename T = DefaultSampleType>
16 class /*LIBAUDIOGRAPHER_API*/ ListedSource : public Source<T>
17 {
18   public:
19         void add_output (typename Source<T>::SinkPtr output) { outputs.push_back(output); }
20         void clear_outputs () { outputs.clear(); }
21         void remove_output (typename Source<T>::SinkPtr output) { outputs.remove(output); }
22
23   protected:
24
25         typedef std::list<typename Source<T>::SinkPtr> SinkList;
26
27         /// Helper for derived classes
28         void output (ProcessContext<T> const & c)
29         {
30                 for (typename SinkList::iterator i = outputs.begin(); i != outputs.end(); ++i) {
31                         (*i)->process (c);
32                 }
33         }
34
35         void output (ProcessContext<T> & c)
36         {
37                 if (output_size_is_one()) {
38                         // only one output, so we can keep this non-const
39                         outputs.front()->process (c);
40                 } else {
41                         output (const_cast<ProcessContext<T> const &> (c));
42                 }
43         }
44
45         inline bool output_size_is_one () { return (!outputs.empty() && ++outputs.begin() == outputs.end()); }
46
47         SinkList outputs;
48 };
49
50 } // namespace
51
52 #endif //AUDIOGRAPHER_LISTED_SOURCE_H
53