Browse Source

Trade: make Abstract{Image,Scene}Converter::doConvertToFile() protected.

This is already done for the AbstractImporter and the new
AbstractShaderConverter, as there's a common use case of checking just
the filename for input/output path or file type detection and then
delegating to the common implementation working directly on data.
pull/527/head
Vladimír Vondruš 5 years ago
parent
commit
c1c02dea58
  1. 7
      doc/changelog.dox
  2. 136
      src/Magnum/Trade/AbstractImageConverter.h
  3. 22
      src/Magnum/Trade/AbstractSceneConverter.h

7
doc/changelog.dox

@ -335,6 +335,13 @@ See also:
@subsubsection changelog-latest-changes-trade Trade library
- @ref Trade::AbstractImageConverter::doConvertToFile() and
@ref Trade::AbstractSceneConverter::doConvertToFile() are now
@cpp protected @ce instead of @cpp private @ce to allow calling them from
plugin implementations and reuse the provided fallback to
@relativeref{Trade::AbstractImageConverter,doConvertToData()}, for example
when the implementation only neeeds to do a format detection based on file
extension
- Recognizing TIFF file header magic in @ref Trade::AnyImageImporter "AnyImageImporter"
- @ref Audio::AnyImporter "AnyAudioImporter",
@relativeref{Trade,AnyImageImporter}, @relativeref{Trade,AnyImageConverter},

136
src/Magnum/Trade/AbstractImageConverter.h

@ -870,6 +870,82 @@ class MAGNUM_TRADE_EXPORT AbstractImageConverter: public PluginManager::Abstract
*/
bool convertToFile(const ImageData3D& image, Containers::StringView filename);
protected:
/**
* @brief Implementation for @ref convertToFile(const ImageView1D&, Containers::StringView)
* @m_since_latest
*
* If @ref ImageConverterFeature::Convert1DToData is supported, default
* implementation calls @ref doConvertToData(const ImageView1D&) and
* saves the result to given file. It is allowed to call this function
* from your @ref doConvertToFile() implementation, for example when
* you only need to do format detection based on file extension.
*/
virtual bool doConvertToFile(const ImageView1D& image, Containers::StringView filename);
/**
* @brief Implementation for @ref convertToFile(const ImageView2D&, Containers::StringView)
* @m_since_latest
*
* If @ref ImageConverterFeature::Convert2DToData is supported, default
* implementation calls @ref doConvertToData(const ImageView2D&) and
* saves the result to given file. It is allowed to call this function
* from your @ref doConvertToFile() implementation, for example when
* you only need to do format detection based on file extension.
*/
virtual bool doConvertToFile(const ImageView2D& image, Containers::StringView filename);
/**
* @brief Implementation for @ref convertToFile(const ImageView3D&, Containers::StringView)
* @m_since_latest
*
* If @ref ImageConverterFeature::Convert3DToData is supported, default
* implementation calls @ref doConvertToData(const ImageView3D&) and
* saves the result to given file. It is allowed to call this function
* from your @ref doConvertToFile() implementation, for example when
* you only need to do format detection based on file extension.
*/
virtual bool doConvertToFile(const ImageView3D& image, Containers::StringView filename);
/**
* @brief Implementation for @ref convertToFile(const CompressedImageView1D&, Containers::StringView)
* @m_since_latest
*
* If @ref ImageConverterFeature::ConvertCompressed1DToData is
* supported, default implementation calls @ref doConvertToData(const CompressedImageView1D&)
* and saves the result to given file. It is allowed to call this
* function from your @ref doConvertToFile() implementation, for
* example when you only need to do format detection based on file
* extension.
*/
virtual bool doConvertToFile(const CompressedImageView1D& image, Containers::StringView filename);
/**
* @brief Implementation for @ref convertToFile(const CompressedImageView2D&, Containers::StringView)
* @m_since_latest
*
* If @ref ImageConverterFeature::ConvertCompressed2DToData is
* supported, default implementation calls @ref doConvertToData(const CompressedImageView2D&)
* and saves the result to given file. It is allowed to call this
* function from your @ref doConvertToFile() implementation, for
* example when you only need to do format detection based on file
* extension.
*/
virtual bool doConvertToFile(const CompressedImageView2D& image, Containers::StringView filename);
/**
* @brief Implementation for @ref convertToFile(const CompressedImageView3D&, Containers::StringView)
* @m_since_latest
*
* If @ref ImageConverterFeature::ConvertCompressed3DToData is
* supported, default implementation calls @ref doConvertToData(const CompressedImageView3D&)
* and saves the result to given file. It is allowed to call this
* function from your @ref doConvertToFile() implementation, for
* example when you only need to do format detection based on file
* extension.
*/
virtual bool doConvertToFile(const CompressedImageView3D& image, Containers::StringView filename);
private:
/** @brief Implementation for @ref features() */
virtual ImageConverterFeatures doFeatures() const = 0;
@ -962,66 +1038,6 @@ class MAGNUM_TRADE_EXPORT AbstractImageConverter: public PluginManager::Abstract
*/
virtual Containers::Array<char> doConvertToData(const CompressedImageView3D& image);
/**
* @brief Implementation for @ref convertToFile(const ImageView1D&, Containers::StringView)
* @m_since_latest
*
* If @ref ImageConverterFeature::Convert1DToData is supported, default
* implementation calls @ref doConvertToData(const ImageView1D&) and
* saves the result to given file.
*/
virtual bool doConvertToFile(const ImageView1D& image, Containers::StringView filename);
/**
* @brief Implementation for @ref convertToFile(const ImageView2D&, Containers::StringView)
* @m_since_latest
*
* If @ref ImageConverterFeature::Convert2DToData is supported, default
* implementation calls @ref doConvertToData(const ImageView2D&) and
* saves the result to given file.
*/
virtual bool doConvertToFile(const ImageView2D& image, Containers::StringView filename);
/**
* @brief Implementation for @ref convertToFile(const ImageView3D&, Containers::StringView)
* @m_since_latest
*
* If @ref ImageConverterFeature::Convert3DToData is supported, default
* implementation calls @ref doConvertToData(const ImageView3D&) and
* saves the result to given file.
*/
virtual bool doConvertToFile(const ImageView3D& image, Containers::StringView filename);
/**
* @brief Implementation for @ref convertToFile(const CompressedImageView1D&, Containers::StringView)
* @m_since_latest
*
* If @ref ImageConverterFeature::ConvertCompressed1DToData is
* supported, default implementation calls @ref doConvertToData(const CompressedImageView1D&)
* and saves the result to given file.
*/
virtual bool doConvertToFile(const CompressedImageView1D& image, Containers::StringView filename);
/**
* @brief Implementation for @ref convertToFile(const CompressedImageView2D&, Containers::StringView)
* @m_since_latest
*
* If @ref ImageConverterFeature::ConvertCompressed2DToData is
* supported, default implementation calls @ref doConvertToData(const CompressedImageView2D&)
* and saves the result to given file.
*/
virtual bool doConvertToFile(const CompressedImageView2D& image, Containers::StringView filename);
/**
* @brief Implementation for @ref convertToFile(const CompressedImageView3D&, Containers::StringView)
* @m_since_latest
*
* If @ref ImageConverterFeature::ConvertCompressed3DToData is
* supported, default implementation calls @ref doConvertToData(const CompressedImageView3D&)
* and saves the result to given file.
*/
virtual bool doConvertToFile(const CompressedImageView3D& image, Containers::StringView filename);
ImageConverterFlags _flags;
};

22
src/Magnum/Trade/AbstractSceneConverter.h

@ -318,6 +318,19 @@ class MAGNUM_TRADE_EXPORT AbstractSceneConverter: public PluginManager::Abstract
CORRADE_DEPRECATED("use convertToFile(const MeshData&, Containers::StringView) instead") bool convertToFile(const std::string& filename, const MeshData& mesh);
#endif
protected:
/**
* @brief Implementation for @ref convertToFile(const MeshData&, Containers::StringView)
*
* If @ref SceneConverterFeature::ConvertMeshToData is supported,
* default implementation calls @ref doConvertToData(const MeshData&)
* and saves the result to given file. It is allowed to call this
* function from your @ref doConvertToFile() implementation, for
* example when you only need to do format detection based on file
* extension.
*/
virtual bool doConvertToFile(const MeshData& mesh, Containers::StringView filename);
private:
/**
* @brief Implementation for @ref features()
@ -350,15 +363,6 @@ class MAGNUM_TRADE_EXPORT AbstractSceneConverter: public PluginManager::Abstract
/** @brief Implementation for @ref convertToData(const MeshData&) */
virtual Containers::Array<char> doConvertToData(const MeshData& mesh);
/**
* @brief Implementation for @ref convertToFile(const MeshData&, Containers::StringView)
*
* If @ref SceneConverterFeature::ConvertMeshToData is supported,
* default implementation calls @ref doConvertToData(const MeshData&)
* and saves the result to given file.
*/
virtual bool doConvertToFile(const MeshData& mesh, Containers::StringView filename);
SceneConverterFlags _flags;
};

Loading…
Cancel
Save