diff --git a/Documentation/Doxygen/3-DeveloperManual/Concepts/ReaderWriterPage.md b/Documentation/Doxygen/3-DeveloperManual/Concepts/ReaderWriterPage.md index 0fd39e2de0..0b3e73a2f5 100644 --- a/Documentation/Doxygen/3-DeveloperManual/Concepts/ReaderWriterPage.md +++ b/Documentation/Doxygen/3-DeveloperManual/Concepts/ReaderWriterPage.md @@ -1,90 +1,92 @@ Reader and Writer {#ReaderWriterPage} ================= This page is work in progress and will introduce you to the IO-System of MITK. ## Introductory Slides Several Talks have been given on the IO-System. The following list should provide you with a good starting point. - Introduction to MimeTypes: http://www.mitk.org/images/e/e8/MimeTypes.pdf (by Caspar J. Goch) - Introduction to the IO-System: http://www.mitk.org/images/0/0b/Newio.pdf (by Keno März) - IO-Streams and the new IO System: http://www.mitk.org/images/9/95/Streams.pdf (by Keno März) ## Mime Types The MimeType class provides meta-data about a specific data format. Every mitk::IFileReader and mitk::IFileWriter instance must be associated with exactly one mime-type via a service property. +\imageMacro{mimetypes.png,"",14} + Mime-type are used for categorizing data formats and creating filter strings in file open and save dialogs. Hence they effectively control the accessible set of data formats from a graphical user interface. Minimally, mime-types should provide a name and a list of handled extensions in lower case. Additionally, it is highly enouraged to set a category and a comment which will provide user-readable strings for user interaction. It is important to understand the difference between mitk::MimeType and mitk::CustomMimeType. The former is an immutable stack object and can be pulled from mitk::MimeTypeProvider. it should be used for all interaction with MimeTypes. mitk::CustomMimeType is the heap-object pendant which is wrapped by mitk::MimeType and should exclusively be used for registration purposes, i.e. when you register a new MimeType. ## The IFileReader interface This is the main interface for reading data from files or streams. However, instances of this interface are rarely used directly. See the mitk::IOUtil section below. ## The IFileWriter interface This is the main interface for writing data to files or streams. However, instances of this interface are rarely used directly. See the mitk::IOUtil section below. ## Ranking strategies Todo. ## Convenience classes Developers usually do not interact with the service registry directly to retrieve and select a matching mitk::IFileReader or mitk::IFileWriter instance. ### IOUtil This class provides convenience methods for loading data into a data storage or just returning BaseData objects. The mitk::IOUtil::Save() and mitk::IOUtil::Load() methods cover thy typical use cases and automatically select the best matching mitk::IFileReader and mitk::IFileWriter instance. ### %QmitkIOUtil The QmitkIOUtil class is a wrapper around mitk::IOUtil, providing file open and save dialogs for selecting a file name from a within a graphical user interface. ### FileReaderRegistry and FileWriterRegistry Access to mitk::IFileReader and mitk::IFileWriter objects and their service references. ## Integrating external I/O mechanisms The MITK I/O system integrates with several external I/O systems. ### ITK Reader and Writer The I/O classes from ITK are automatically added to the service registry of MITK. They can be transparently used via the mitk::IFileReader and mitk::IFileWriter interfaces or the mitk::IOUtil methods. ### VTK Reader and Writer VTK does not provide a mechanism to enumerate all available I/O classes. Hence MITK provides manual integration of a specific set of VTK readers and writers. ## Error handling and recovery Todo. diff --git a/Documentation/Doxygen/3-DeveloperManual/Concepts/images/readerwriter/mimetypes.png b/Documentation/Doxygen/3-DeveloperManual/Concepts/images/readerwriter/mimetypes.png new file mode 100644 index 0000000000..68ee1aaa5a Binary files /dev/null and b/Documentation/Doxygen/3-DeveloperManual/Concepts/images/readerwriter/mimetypes.png differ diff --git a/Modules/Core/include/mitkCustomMimeType.h b/Modules/Core/include/mitkCustomMimeType.h index a1d5e30644..d65cd6a4e7 100644 --- a/Modules/Core/include/mitkCustomMimeType.h +++ b/Modules/Core/include/mitkCustomMimeType.h @@ -1,139 +1,137 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKCUSTOMMIMETYPE_H #define MITKCUSTOMMIMETYPE_H #include #include #include #include namespace mitk { class MimeType; /** * @ingroup IO * @ingroup MicroServices_Interfaces * * @brief The CustomMimeType class represents a custom mime-type which * may be registered as a service object. It should only be used for mime-type registration, * see also mitk::MimeType. * * Instances of this class are usually created and registered as a service. * They act as meta data information to allow the linking of files to reader and writer. * They write files to specific IFileReader instances and provide data format * meta-data for selecting compatible IFileWriter instances. * mirk::CustomMimetype should only be used to register mime-types. All other interaction should happen trough * mitk::MimeTypeProvider, from which registered mimetypes can be pulled. mitk::MimeType provides a safe and memory-managed * way of interacting with Mimetypes. - * - * */ class MITKCORE_EXPORT CustomMimeType { public: CustomMimeType(); CustomMimeType(const std::string& name); CustomMimeType(const CustomMimeType& other); explicit CustomMimeType(const MimeType& other); virtual ~CustomMimeType(); CustomMimeType& operator=(const CustomMimeType& other); CustomMimeType& operator=(const MimeType& other); /** * \brief Returns the unique name for the MimeType. */ std::string GetName() const; /** * \brief Returns the human-readable Category of the mime-type. Allows grouping of similar mime-types (like Surfaces) */ std::string GetCategory() const; /** * \brief Returns all extensions that this MimeType can handle. */ std::vector GetExtensions() const; /** * \brief Returns the Human readable comment of the MimeType, a string that describes its unique role. */ std::string GetComment() const; /** * \brief Checks if the MimeType can handle file at the given location. * * In its base implementation, this function exclusively looks a the given string. * However, child classes can override this behaviour and peek into the file. */ virtual bool AppliesTo(const std::string& path) const; /** * \brief Checks if the MimeType can handle the etension of the given path * * This function exclusively looks a the given string */ bool MatchesExtension(const std::string& path) const; /** * \brief Provides the first matching extension * * Checks whether any of its extensions are present at the end of the provided path. * Returns the first found one. */ std::string GetExtension(const std::string& path) const; /** * \brief Provides the filename minus the extension * * Checks whether any of its extensions are present at the end of the provided path. * Returns the filename without that extension and without the directory. */ std::string GetFilenameWithoutExtension(const std::string& path) const; void SetName(const std::string& name); void SetCategory(const std::string& category); void SetExtension(const std::string& extension); void AddExtension(const std::string& extension); void SetComment(const std::string& comment); void Swap(CustomMimeType& r); virtual CustomMimeType* Clone() const; private: // returns true if an extension was found bool ParsePathForExtension(const std::string& path, std::string& extension, std::string& filename ) const; struct Impl; Impl* d; }; void swap(CustomMimeType& l, CustomMimeType& r); } MITK_DECLARE_SERVICE_INTERFACE(mitk::CustomMimeType, "org.mitk.CustomMimeType") #endif // MITKCUSTOMMIMETYPE_H