Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkMimeTypeProvider.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 mitkMimeTypeProvider_h
14 #define mitkMimeTypeProvider_h
15 
16 #include <mitkCustomMimeType.h>
17 #include <mitkIMimeTypeProvider.h>
18 
19 #include <usServiceTracker.h>
21 
22 #include <set>
23 
24 namespace mitk
25 {
31  struct MimeTypeTrackerTypeTraits : public us::TrackedTypeTraitsBase<MimeType, MimeTypeTrackerTypeTraits>
32  {
34 
35  static bool IsValid(const TrackedType &t) { return t.IsValid(); }
36  static TrackedType DefaultValue() { return TrackedType(); }
37  static void Dispose(TrackedType & /*t*/) {}
38  };
39 
52  class MimeTypeProvider : public IMimeTypeProvider, private us::ServiceTrackerCustomizer<CustomMimeType, MimeType>
53  {
54  public:
56  ~MimeTypeProvider() override;
57 
63  void Start();
64 
70  void Stop();
71 
76  std::vector<MimeType> GetMimeTypes() const override;
77 
86  std::vector<MimeType> GetMimeTypesForFile(const std::string &filePath) const override;
87 
93  std::vector<MimeType> GetMimeTypesForCategory(const std::string &category) const override;
94 
100  MimeType GetMimeTypeForName(const std::string &name) const override;
101 
106  std::vector<std::string> GetCategories() const override;
107 
108  private:
109  TrackedType AddingService(const ServiceReferenceType &reference) override;
110  void ModifiedService(const ServiceReferenceType &reference, TrackedType service) override;
111  void RemovedService(const ServiceReferenceType &reference, TrackedType service) override;
112 
118  MimeType GetMimeType(const ServiceReferenceType &reference) const;
119 
121 
122  typedef std::map<std::string, std::set<MimeType>> MapType;
123  MapType m_NameToMimeTypes;
124 
125  std::map<std::string, MimeType> m_NameToMimeType;
126  };
127 }
128 
129 #endif
Implementation of IMimeTypeProvider that tracks MIME type services.
std::vector< MimeType > GetMimeTypesForCategory(const std::string &category) const override
Get all MIME types belonging to the given category.
void Start()
Start tracking MIME type services.
void Stop()
Stop tracking MIME type services.
std::vector< MimeType > GetMimeTypes() const override
Get all currently registered MIME types (highest-ranked per name).
std::vector< MimeType > GetMimeTypesForFile(const std::string &filePath) const override
Get all MIME types that match the given file path.
~MimeTypeProvider() override
std::vector< std::string > GetCategories() const override
Get all unique MIME type categories.
MimeType GetMimeTypeForName(const std::string &name) const override
Get the highest-ranked MIME type with the given name.
Immutable, value-type wrapper for a registered mime-type.
Definition: mitkMimeType.h:45
bool IsValid() const
Check whether this MimeType object is valid (has a non-empty name).
Find image slices visible on a given plane.
Service interface for querying all registered mime-types.
Custom traits for tracking MimeType objects via CppMicroServices ServiceTracker.
static void Dispose(TrackedType &)
static bool IsValid(const TrackedType &t)