c@51: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
c@51: 
c@51: /*
c@51:     Vampipe
c@51: 
c@51:     Centre for Digital Music, Queen Mary, University of London.
c@51:     Copyright 2006-2016 Chris Cannam and QMUL.
c@51:   
c@51:     Permission is hereby granted, free of charge, to any person
c@51:     obtaining a copy of this software and associated documentation
c@51:     files (the "Software"), to deal in the Software without
c@51:     restriction, including without limitation the rights to use, copy,
c@51:     modify, merge, publish, distribute, sublicense, and/or sell copies
c@51:     of the Software, and to permit persons to whom the Software is
c@51:     furnished to do so, subject to the following conditions:
c@51: 
c@51:     The above copyright notice and this permission notice shall be
c@51:     included in all copies or substantial portions of the Software.
c@51: 
c@51:     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
c@51:     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
c@51:     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
c@51:     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
c@51:     ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
c@51:     CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
c@51:     WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
c@51: 
c@51:     Except as contained in this notice, the names of the Centre for
c@51:     Digital Music; Queen Mary, University of London; and Chris Cannam
c@51:     shall not be used in advertising or otherwise to promote the sale,
c@51:     use or other dealings in this Software without prior written
c@51:     authorization.
c@51: */
c@51: 
c@51: #ifndef VAMPIPE_PRESERVING_PLUGIN_OUTPUT_ID_MAPPER_H
c@51: #define VAMPIPE_PRESERVING_PLUGIN_OUTPUT_ID_MAPPER_H
c@51: 
c@51: #include "PluginOutputIdMapper.h"
c@51: 
c@51: #include <iostream>
c@51: 
c@51: namespace vampipe {
c@51: 
c@51: //!!! document -- this is a passthrough thing that invents its
c@51: //!!! numerical ids, they have no correspondence with any real plugin
c@51: 
c@51: class PreservingPluginOutputIdMapper : public PluginOutputIdMapper
c@51: {
c@51: public:
c@51:     PreservingPluginOutputIdMapper() { }
c@51: 
c@51:     virtual int idToIndex(std::string outputId) const {
c@51: 	int n = int(m_ids.size());
c@51: 	int i = 0;
c@51: 	while (i < n) {
c@51: 	    if (outputId == m_ids[i]) {
c@51: 		return i;
c@51: 	    }
c@51: 	    ++i;
c@51: 	}
c@51: 	m_ids.push_back(outputId);
c@51: 	return i;
c@51:     }
c@51: 
c@51:     virtual std::string indexToId(int index) const {
c@51: 	//!!! todo: this should in fact throw, or otherwise return an error
c@51: 	return m_ids[index];
c@51:     }
c@51: 
c@51: private:
c@51:     mutable std::vector<std::string> m_ids;
c@51: };
c@51: 
c@51: }
c@51: 
c@51: #endif