Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkCustomMimeType.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkCustomMimeType_h
14 #define mitkCustomMimeType_h
15 
16 #include <MitkCoreExports.h>
17 
18 #include <mitkServiceInterface.h>
19 
20 #include <string>
21 #include <vector>
22 
23 namespace mitk
24 {
25  class MimeType;
26 
50  {
51  public:
56 
62  CustomMimeType(const std::string &name);
63 
69 
74  explicit CustomMimeType(const MimeType &other);
75 
76  virtual ~CustomMimeType();
77 
84 
91 
96  std::string GetName() const;
97 
103  std::string GetCategory() const;
104 
109  std::vector<std::string> GetExtensions() const;
110 
116  std::string GetComment() const;
117 
126  virtual bool AppliesTo(const std::string &path) const;
127 
136  bool MatchesExtension(const std::string &path) const;
137 
143  std::string GetExtension(const std::string &path) const;
144 
151  std::string GetFilenameWithoutExtension(const std::string &path) const;
152 
157  void SetName(const std::string &name);
158 
163  void SetCategory(const std::string &category);
164 
169  void SetExtension(const std::string &extension);
170 
175  void AddExtension(const std::string &extension);
176 
181  void SetComment(const std::string &comment);
182 
188 
193  virtual CustomMimeType *Clone() const;
194 
195  private:
196  // returns true if an extension was found
197  bool ParsePathForExtension(const std::string &path, std::string &extension, std::string &filename) const;
198 
199  struct Impl;
200  Impl *d;
201  };
202 
209 }
210 
211 MITK_DECLARE_SERVICE_INTERFACE(mitk::CustomMimeType, "org.mitk.CustomMimeType")
212 
213 #endif
#define MITKCORE_EXPORT
A custom mime-type that can be registered as a service object.
bool MatchesExtension(const std::string &path) const
Check whether the file extension of the given path matches this mime-type.
CustomMimeType(const CustomMimeType &other)
Copy constructor.
std::vector< std::string > GetExtensions() const
Get all file extensions this mime-type can handle.
virtual CustomMimeType * Clone() const
Create a heap-allocated copy of this CustomMimeType.
std::string GetComment() const
Get a human-readable description of this mime-type.
void SetExtension(const std::string &extension)
Set a single file extension, replacing all existing extensions.
CustomMimeType(const MimeType &other)
Construct from an immutable MimeType wrapper.
CustomMimeType()
Construct a default CustomMimeType with an empty name.
virtual ~CustomMimeType()
void SetCategory(const std::string &category)
Set the category for grouping this mime-type.
std::string GetFilenameWithoutExtension(const std::string &path) const
Get the filename from the given path, without the matching extension.
void AddExtension(const std::string &extension)
Add a file extension to the list if not already present (case-insensitive).
std::string GetCategory() const
Get the human-readable category of this mime-type.
CustomMimeType & operator=(const CustomMimeType &other)
Copy assignment operator.
void SetName(const std::string &name)
Set the unique name of this mime-type.
void Swap(CustomMimeType &r)
Swap the contents of this CustomMimeType with another.
std::string GetExtension(const std::string &path) const
Get the first matching extension found at the end of the given path.
CustomMimeType(const std::string &name)
Construct a CustomMimeType with the given unique name.
void SetComment(const std::string &comment)
Set the human-readable comment for this mime-type.
std::string GetName() const
Get the unique name for this mime-type.
CustomMimeType & operator=(const MimeType &other)
Assignment from an immutable MimeType wrapper.
virtual bool AppliesTo(const std::string &path) const
Check whether this mime-type can handle the file at the given path.
Immutable, value-type wrapper for a registered mime-type.
Definition: mitkMimeType.h:45
Provides the MITK_DECLARE_SERVICE_INTERFACE macro for registering C++ interfaces with both the CppMic...
#define MITK_DECLARE_SERVICE_INTERFACE(IFace, IId)
Declare a C++ interface for use with CppMicroServices (Qt not available).
Find image slices visible on a given plane.
void swap(CustomMimeType &l, CustomMimeType &r)
Swap two CustomMimeType objects.