Medical Imaging Interaction Toolkit  2025.12.02
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 
45  {
46  public:
48  CustomMimeType(const std::string &name);
50  explicit CustomMimeType(const MimeType &other);
51 
52  virtual ~CustomMimeType();
53 
56 
60  std::string GetName() const;
61 
65  std::string GetCategory() const;
66 
70  std::vector<std::string> GetExtensions() const;
71 
75  std::string GetComment() const;
76 
83  virtual bool AppliesTo(const std::string &path) const;
84 
90  bool MatchesExtension(const std::string &path) const;
91 
98  std::string GetExtension(const std::string &path) const;
99 
106  std::string GetFilenameWithoutExtension(const std::string &path) const;
107 
108  void SetName(const std::string &name);
109  void SetCategory(const std::string &category);
110  void SetExtension(const std::string &extension);
111  void AddExtension(const std::string &extension);
112  void SetComment(const std::string &comment);
113 
115 
116  virtual CustomMimeType *Clone() const;
117 
118  private:
119  // returns true if an extension was found
120  bool ParsePathForExtension(const std::string &path, std::string &extension, std::string &filename) const;
121 
122  struct Impl;
123  Impl *d;
124  };
125 
127 }
128 
129 MITK_DECLARE_SERVICE_INTERFACE(mitk::CustomMimeType, "org.mitk.CustomMimeType")
130 
131 #endif
#define MITKCORE_EXPORT
The CustomMimeType class represents a custom mime-type which may be registered as a service object....
bool MatchesExtension(const std::string &path) const
Checks if the MimeType can handle the extension of the given path.
CustomMimeType(const CustomMimeType &other)
std::vector< std::string > GetExtensions() const
Returns all extensions that this MimeType can handle.
virtual CustomMimeType * Clone() const
std::string GetComment() const
Returns the Human readable comment of the MimeType, a string that describes its unique role.
void SetExtension(const std::string &extension)
CustomMimeType(const MimeType &other)
virtual ~CustomMimeType()
void SetCategory(const std::string &category)
std::string GetFilenameWithoutExtension(const std::string &path) const
Provides the filename minus the extension.
void AddExtension(const std::string &extension)
std::string GetCategory() const
Returns the human-readable Category of the mime-type. Allows grouping of similar mime-types (like Sur...
CustomMimeType & operator=(const CustomMimeType &other)
void SetName(const std::string &name)
void Swap(CustomMimeType &r)
std::string GetExtension(const std::string &path) const
Provides the first matching extension.
CustomMimeType(const std::string &name)
void SetComment(const std::string &comment)
std::string GetName() const
Returns the unique name for the MimeType.
CustomMimeType & operator=(const MimeType &other)
virtual bool AppliesTo(const std::string &path) const
Checks if the MimeType can handle file at the given location.
The MimeType class represents a registered mime-type. It is an immutable wrapper for mitk::CustomMime...
Definition: mitkMimeType.h:37
#define MITK_DECLARE_SERVICE_INTERFACE(IFace, IId)
Find image slices visible on a given plane.
void swap(CustomMimeType &l, CustomMimeType &r)