/* 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_CONVERTERS_DATACONVERTERS_PRIMITIVECONVERTERSRH_H #define SRC_COMMON_CPP_CONVERTERS_DATACONVERTERS_PRIMITIVECONVERTERSRH_H #include #include "src/common_cpp/Converter/DataConverters/JsonCppRunHeaderConverter.hh" #include "src/common_cpp/Converter/DataConverters/CppJsonRunHeaderConverter.hh" namespace MAUS { class RunHeaderData; /////////////////////////// X TO RunHeaderData //////////////////////////// class StringRunHeaderConverter : public ConverterBase { public: StringRunHeaderConverter() : ConverterBase("StringRunHeaderConverter") {} private: RunHeaderData* _convert(const std::string* str) const { Json::Value* json = StringJsonConverter().convert(str); RunHeaderData* jh = JsonCppRunHeaderConverter().convert(json); delete json; return jh; } }; class PyDictRunHeaderConverter : public ConverterBase { public: PyDictRunHeaderConverter() : ConverterBase("PyDictRunHeaderConverter") {} private: RunHeaderData* _convert(const PyObject* obj) const { std::string* str = PyDictStringConverter().convert(obj); RunHeaderData* jh = StringRunHeaderConverter().convert(str); delete str; return jh; } }; /////////////////////////// RunHeaderData TO X //////////////////////////// class RunHeaderStringConverter : public ConverterBase { public: RunHeaderStringConverter() : ConverterBase("RunHeaderStringConverter") {} private: std::string* _convert(const RunHeaderData* jh) const { Json::Value* json = CppJsonRunHeaderConverter().convert(jh); std::string* str = JsonStringConverter().convert(json); delete json; return str; } }; class RunHeaderRunHeaderConverter : public ConverterBase { public: RunHeaderRunHeaderConverter() : ConverterBase("RunHeaderRunHeaderConverter") {} private: RunHeaderData* _convert(const RunHeaderData* jh) const { return new RunHeaderData(*jh); } }; class RunHeaderPyDictConverter : public ConverterBase { public: RunHeaderPyDictConverter() : ConverterBase("RunHeaderPyDictConverter") {} private: PyObject* _convert(const RunHeaderData* jh) const { std::string* str = RunHeaderStringConverter().convert(jh); PyObject* obj = StringPyDictConverter().convert(str); delete str; return obj; } }; } #endif // SRC_COMMON_CPP_CONVERTERS_DATACONVERTERS_PRIMITIVECONVERTERSRH_H