00001 /*************************************************************************** 00002 * * 00003 * Copyright (C) 2007, 2008 Grigor Iliev * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the Free Software * 00017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * 00018 * MA 02110-1301 USA * 00019 ***************************************************************************/ 00020 00021 #ifndef __LS_EVENTLISTENERS_H__ 00022 #define __LS_EVENTLISTENERS_H__ 00023 00024 #include <vector> 00025 #include "common/global.h" 00026 00027 namespace LinuxSampler { 00028 00029 // just symbol prototyping 00030 class SamplerChannel; 00031 class MidiInputDevice; 00032 class MidiInputPort; 00033 00034 template<class L> 00035 class ListenerList { 00036 public: 00040 void AddListener(L l) { 00041 vListenerList.push_back(l); 00042 } 00043 00047 void RemoveListener(L l) { 00048 typename std::vector<L>::iterator it; 00049 it = vListenerList.begin(); 00050 for (; it != vListenerList.end(); it++) { 00051 if (*it == l) { 00052 vListenerList.erase(it); 00053 return; 00054 } 00055 } 00056 } 00057 00061 void RemoveAllListeners() { 00062 vListenerList.clear(); 00063 } 00064 00068 int GetListenerCount() { 00069 return vListenerList.size(); 00070 } 00071 00076 L GetListener(int index) { 00077 return vListenerList.at(index); 00078 } 00079 00080 private: 00081 std::vector<L> vListenerList; 00082 }; 00083 00088 class ChannelCountListener { 00089 public: 00094 virtual void ChannelCountChanged(int NewCount) = 0; 00095 virtual void ChannelAdded(SamplerChannel* pChannel) = 0; 00096 virtual void ChannelToBeRemoved(SamplerChannel* pChannel) = 0; 00097 }; 00098 00103 class ChannelCountAdapter : public ChannelCountListener { 00104 public: 00105 virtual void ChannelCountChanged(int NewCount) { }; 00106 virtual void ChannelAdded(SamplerChannel* pChannel) { }; 00107 virtual void ChannelToBeRemoved(SamplerChannel* pChannel) { }; 00108 }; 00109 00114 class AudioDeviceCountListener { 00115 public: 00120 virtual void AudioDeviceCountChanged(int NewCount) = 0; 00121 }; 00122 00127 class MidiDeviceCountListener { 00128 public: 00133 virtual void MidiDeviceCountChanged(int NewCount) = 0; 00134 00140 virtual void MidiDeviceToBeDestroyed(MidiInputDevice* pDevice) = 0; 00141 00147 virtual void MidiDeviceCreated(MidiInputDevice* pDevice) = 0; 00148 }; 00149 00154 class MidiPortCountListener { 00155 public: 00160 virtual void MidiPortCountChanged(int NewCount) = 0; 00161 00167 virtual void MidiPortToBeRemoved(MidiInputPort* pPort) = 0; 00168 00174 virtual void MidiPortAdded(MidiInputPort* pPort) = 0; 00175 }; 00176 00181 class MidiInstrumentCountListener { 00182 public: 00188 virtual void MidiInstrumentCountChanged(int MapId, int NewCount) = 0; 00189 }; 00190 00195 class MidiInstrumentInfoListener { 00196 public: 00203 virtual void MidiInstrumentInfoChanged(int MapId, int Bank, int Program) = 0; 00204 }; 00205 00210 class MidiInstrumentMapCountListener { 00211 public: 00216 virtual void MidiInstrumentMapCountChanged(int NewCount) = 0; 00217 }; 00218 00223 class MidiInstrumentMapInfoListener { 00224 public: 00229 virtual void MidiInstrumentMapInfoChanged(int MapId) = 0; 00230 }; 00231 00236 class FxSendCountListener { 00237 public: 00244 virtual void FxSendCountChanged(int ChannelId, int NewCount) = 0; 00245 }; 00246 00251 class VoiceCountListener { 00252 public: 00259 virtual void VoiceCountChanged(int ChannelId, int NewCount) = 0; 00260 }; 00261 00266 class StreamCountListener { 00267 public: 00274 virtual void StreamCountChanged(int ChannelId, int NewCount) = 0; 00275 }; 00276 00281 class BufferFillListener { 00282 public: 00289 virtual void BufferFillChanged(int ChannelId, String FillData) = 0; 00290 }; 00291 00296 class TotalStreamCountListener { 00297 public: 00302 virtual void TotalStreamCountChanged(int NewCount) = 0; 00303 }; 00304 00309 class TotalVoiceCountListener { 00310 public: 00315 virtual void TotalVoiceCountChanged(int NewCount) = 0; 00316 }; 00317 00322 class EngineChangeListener { 00323 public: 00329 virtual void EngineToBeChanged(int ChannelId) = 0; 00330 00337 virtual void EngineChanged(int ChannelId) = 0; 00338 }; 00339 } 00340 #endif