Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef MITKMIMETYPEPROVIDER_H
18 #define MITKMIMETYPEPROVIDER_H
19 
20 #include "mitkCustomMimeType.h"
21 #include "mitkIMimeTypeProvider.h"
22 
23 #include "usServiceTracker.h"
25 
26 #include <set>
27 
28 namespace mitk
29 {
30  struct MimeTypeTrackerTypeTraits : public us::TrackedTypeTraitsBase<MimeType, MimeTypeTrackerTypeTraits>
31  {
33 
34  static bool IsValid(const TrackedType &t) { return t.IsValid(); }
35  static TrackedType DefaultValue() { return TrackedType(); }
36  static void Dispose(TrackedType & /*t*/) {}
37  };
38 
39  class MimeTypeProvider : public IMimeTypeProvider, private us::ServiceTrackerCustomizer<CustomMimeType, MimeType>
40  {
41  public:
44 
45  void Start();
46  void Stop();
47 
48  virtual std::vector<MimeType> GetMimeTypes() const override;
49  virtual std::vector<MimeType> GetMimeTypesForFile(const std::string &filePath) const override;
50  virtual std::vector<MimeType> GetMimeTypesForCategory(const std::string &category) const override;
51  virtual MimeType GetMimeTypeForName(const std::string &name) const override;
52 
53  virtual std::vector<std::string> GetCategories() const override;
54 
55  private:
56  virtual TrackedType AddingService(const ServiceReferenceType &reference) override;
57  virtual void ModifiedService(const ServiceReferenceType &reference, TrackedType service) override;
58  virtual void RemovedService(const ServiceReferenceType &reference, TrackedType service) override;
59 
60  MimeType GetMimeType(const ServiceReferenceType &reference) const;
61 
63 
64  typedef std::map<std::string, std::set<MimeType>> MapType;
65  MapType m_NameToMimeTypes;
66 
67  std::map<std::string, MimeType> m_NameToMimeType;
68  };
69 }
70 
71 #endif // MITKMIMETYPEPROVIDER_H
bool IsValid() const
DataCollection - Class to facilitate loading/accessing structured data.
virtual MimeType GetMimeTypeForName(const std::string &name) const override
virtual std::vector< MimeType > GetMimeTypesForFile(const std::string &filePath) const override
The IMimeTypeProvider service interface allows to query all registered mime types.
virtual std::vector< MimeType > GetMimeTypes() const override
The MimeType class represens a registered mime-type. It is an immutable wrapper for mitk::CustomMimeT...
Definition: mitkMimeType.h:45
virtual std::vector< std::string > GetCategories() const override
Get a sorted and unique list of mime-type categories.
static bool IsValid(const TrackedType &t)
virtual std::vector< MimeType > GetMimeTypesForCategory(const std::string &category) const override
static void Dispose(TrackedType &)