/**************************************************************************** ** Copyright (c) 2023, Fougue Ltd. ** All rights reserved. ** See license at https://github.com/fougue/mayo/blob/master/LICENSE.txt ****************************************************************************/ #pragma once #include "../base/io_reader.h" #include "../base/io_writer.h" namespace Mayo { namespace IO { template class SingleFormatFactoryReader : public FactoryReader { public: Span formats() const override; std::unique_ptr create(Format format) const override; std::unique_ptr createProperties(Format format, PropertyGroup* parentGroup) const override; }; template class SingleFormatFactoryWriter : public FactoryWriter { public: Span formats() const override; std::unique_ptr create(Format format) const override; std::unique_ptr createProperties(Format format, PropertyGroup* parentGroup) const override; }; // -- // -- Implementation // -- template Span SingleFormatFactoryReader::formats() const { static const Format arrayFormat[] = { Fmt }; return arrayFormat; } template std::unique_ptr SingleFormatFactoryReader::create(Format format) const { if (format == Fmt) return std::make_unique(); else return {}; } template std::unique_ptr SingleFormatFactoryReader::createProperties(Format format, PropertyGroup* parentGroup) const { if (format == Fmt) return FormatReader::createProperties(parentGroup); else return {}; } template Span SingleFormatFactoryWriter::formats() const { static const Format arrayFormat[] = { Fmt }; return arrayFormat; } template std::unique_ptr SingleFormatFactoryWriter::create(Format format) const { if (format == Fmt) return std::make_unique(); else return {}; } template std::unique_ptr SingleFormatFactoryWriter::createProperties(Format format, PropertyGroup* parentGroup) const { if (format == Fmt) return FormatWriter::createProperties(parentGroup); else return {}; } } // namespace IO } // namespace Mayo