/* 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/JsonCppSpillConverter.hh" #include "src/common_cpp/Converter/DataConverters/CppJsonSpillConverter.hh" #include "src/common_cpp/Converter/DataConverters/PrimitiveConverters.hh" namespace Json { class Value; } namespace MAUS { class Spill; // 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 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 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(); } /// 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 PyDictPyDictConverter(); } template <> inline IConverter* ConverterFactory::getConverter() const { return new PyDictStringConverter(); } } // end of namespace #endif