Medical Imaging Interaction Toolkit  2023.12.00
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 {
26  struct MimeTypeTrackerTypeTraits : public us::TrackedTypeTraitsBase<MimeType, MimeTypeTrackerTypeTraits>
27  {
29 
30  static bool IsValid(const TrackedType &t) { return t.IsValid(); }
31  static TrackedType DefaultValue() { return TrackedType(); }
32  static void Dispose(TrackedType & /*t*/) {}
33  };
34 
35  class MimeTypeProvider : public IMimeTypeProvider, private us::ServiceTrackerCustomizer<CustomMimeType, MimeType>
36  {
37  public:
39  ~MimeTypeProvider() override;
40 
41  void Start();
42  void Stop();
43 
44  std::vector<MimeType> GetMimeTypes() const override;
45  std::vector<MimeType> GetMimeTypesForFile(const std::string &filePath) const override;
46  std::vector<MimeType> GetMimeTypesForCategory(const std::string &category) const override;
47  MimeType GetMimeTypeForName(const std::string &name) const override;
48 
49  std::vector<std::string> GetCategories() const override;
50 
51  private:
52  TrackedType AddingService(const ServiceReferenceType &reference) override;
53  void ModifiedService(const ServiceReferenceType &reference, TrackedType service) override;
54  void RemovedService(const ServiceReferenceType &reference, TrackedType service) override;
55 
56  MimeType GetMimeType(const ServiceReferenceType &reference) const;
57 
59 
60  typedef std::map<std::string, std::set<MimeType>> MapType;
61  MapType m_NameToMimeTypes;
62 
63  std::map<std::string, MimeType> m_NameToMimeType;
64  };
65 }
66 
67 #endif
mitk::MimeTypeTrackerTypeTraits::Dispose
static void Dispose(TrackedType &)
Definition: mitkMimeTypeProvider.h:32
mitk::MimeTypeProvider::GetMimeTypesForFile
std::vector< MimeType > GetMimeTypesForFile(const std::string &filePath) const override
mitk::MimeTypeProvider::Stop
void Stop()
mitk::MimeTypeProvider::GetCategories
std::vector< std::string > GetCategories() const override
Get a sorted and unique list of mime-type categories.
mitk::MimeTypeTrackerTypeTraits::IsValid
static bool IsValid(const TrackedType &t)
Definition: mitkMimeTypeProvider.h:30
us::ServiceTracker
Definition: usServiceTracker.h:231
mitkIMimeTypeProvider.h
mitk::MimeTypeProvider::GetMimeTypesForCategory
std::vector< MimeType > GetMimeTypesForCategory(const std::string &category) const override
mitkCustomMimeType.h
mitk::MimeType::IsValid
bool IsValid() const
mitk::MimeTypeTrackerTypeTraits::TrackedType
MimeType TrackedType
Definition: mitkMimeTypeProvider.h:28
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
us::ServiceReference
Definition: usModule.h:40
mitk::MimeTypeProvider
Definition: mitkMimeTypeProvider.h:35
us::ServiceTrackerCustomizer< CustomMimeType, MimeType >::TrackedType
MimeType TrackedType
Definition: usServiceTrackerCustomizer.h:66
mitk::MimeTypeProvider::GetMimeTypes
std::vector< MimeType > GetMimeTypes() const override
mitk::MimeTypeTrackerTypeTraits
Definition: mitkMimeTypeProvider.h:26
mitk::IMimeTypeProvider
The IMimeTypeProvider service interface allows to query all registered mime types.
Definition: mitkIMimeTypeProvider.h:46
mitk::MimeTypeProvider::GetMimeTypeForName
MimeType GetMimeTypeForName(const std::string &name) const override
mitk::MimeTypeTrackerTypeTraits::DefaultValue
static TrackedType DefaultValue()
Definition: mitkMimeTypeProvider.h:31
mitk::MimeTypeProvider::~MimeTypeProvider
~MimeTypeProvider() override
usServiceTracker.h
mitk::MimeTypeProvider::Start
void Start()
usServiceTrackerCustomizer.h
us::TrackedTypeTraitsBase
Definition: usServiceTracker.h:60
us::ServiceTrackerCustomizer
Definition: usServiceTrackerCustomizer.h:63
mitk::MimeTypeProvider::MimeTypeProvider
MimeTypeProvider()
mitk::MimeType
The MimeType class represens a registered mime-type. It is an immutable wrapper for mitk::CustomMimeT...
Definition: mitkMimeType.h:36