/* This file is part of MAUS: http://micewww.pp.rl.ac.uk:8080/projects/maus * * MAUS is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * MAUS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MAUS. If not, see . * */ #ifndef _SRC_COMMON_CPP_CONVERTER_CONVERTERFACTORY_INL_ #define _SRC_COMMON_CPP_CONVERTER_CONVERTERFACTORY_INL_ #include #include "Utils/Exception.hh" #include "src/common_cpp/Utils/CppErrorHandler.hh" #include "src/common_cpp/Converter/DataConverters/PrimitiveConverters.hh" #include "src/common_cpp/Converter/DataConverters/PrimitiveConvertersData.hh" #include "src/common_cpp/Converter/DataConverters/PrimitiveConvertersJobHeader.hh" #include "src/common_cpp/Converter/DataConverters/PrimitiveConvertersJobFooter.hh" #include "src/common_cpp/Converter/DataConverters/PrimitiveConvertersRunHeader.hh" #include "src/common_cpp/Converter/DataConverters/PrimitiveConvertersRunFooter.hh" #include "src/common_cpp/Converter/DataConverters/PrimitiveConvertersImage.hh" namespace Json { class Value; } namespace MAUS { // Template implementation // /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ template OUTPUT* ConverterFactory::convert(INPUT* i) const { // not necessary if each converter does this check // but only if inheriting from converter base, not necessary as long as // implement the IConverter interface so check here anyway IConverter* c = getConverter(); OUTPUT* o = NULL; try { o = c->convert(i); } catch (...) { delete c; throw; } delete c; return o; } /// STRING template <> inline IConverter* ConverterFactory::getConverter() const { return new StringJsonConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new StringDataConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new StringJobHeaderConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new StringJobFooterConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new StringRunHeaderConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new StringRunFooterConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new StringPyDictConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new StringStringConverter(); } /// JSON template <> inline IConverter* ConverterFactory::getConverter() const { return new JsonJsonConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new JsonCppSpillConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new JsonCppJobHeaderConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new JsonCppJobFooterConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new JsonCppRunHeaderConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new JsonCppRunFooterConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new JsonPyDictConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new JsonStringConverter(); } /// Data template <> inline IConverter* ConverterFactory::getConverter() const { return new CppJsonSpillConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new DataDataConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new DataPyDictConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new DataStringConverter(); } /// JobHeaderData template <> inline IConverter* ConverterFactory::getConverter() const { return new CppJsonJobHeaderConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new JobHeaderJobHeaderConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new JobHeaderPyDictConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new JobHeaderStringConverter(); } /// JobFooterData template <> inline IConverter* ConverterFactory::getConverter() const { return new CppJsonJobFooterConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new JobFooterJobFooterConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new JobFooterPyDictConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new JobFooterStringConverter(); } /// RunHeaderData template <> inline IConverter* ConverterFactory::getConverter() const { return new CppJsonRunHeaderConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new RunHeaderRunHeaderConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new RunHeaderPyDictConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new RunHeaderStringConverter(); } /// RunFooterData template <> inline IConverter* ConverterFactory::getConverter() const { return new CppJsonRunFooterConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new RunFooterRunFooterConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new RunFooterPyDictConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new RunFooterStringConverter(); } /// ImageData template <> inline IConverter* ConverterFactory::getConverter() const { return new ImageImageConverter(); } /// PyDICT to X template <> inline IConverter* ConverterFactory::getConverter() const { return new PyDictJsonConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new PyDictDataConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new PyDictJobHeaderConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new PyDictJobFooterConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new PyDictRunHeaderConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new PyDictRunFooterConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new PyDictPyDictConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new PyDictStringConverter(); } // DEFAULT - just throw an exception template IConverter* ConverterFactory::getConverter() const { return new DisallowedConverter(); } } // end of namespace #endif