Medical Imaging Interaction Toolkit  2021.02.99-00f000b3
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 {
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 // MITKMIMETYPEPROVIDER_H
DataCollection - Class to facilitate loading/accessing structured data.
bool IsValid() const
The IMimeTypeProvider service interface allows to query all registered mime types.
The MimeType class represens a registered mime-type. It is an immutable wrapper for mitk::CustomMimeT...
Definition: mitkMimeType.h:36
static bool IsValid(const TrackedType &t)
static void Dispose(TrackedType &)