24 #include <itksys/SystemTools.hxx>
27 #pragma warning(disable : 4503) // decorated name length exceeded, name was truncated
28 #pragma warning(disable : 4355)
37 if (m_Tracker == NULL)
47 std::vector<MimeType> result;
48 for (
const auto &elem : m_NameToMimeType)
50 result.push_back(elem.second);
57 std::vector<MimeType> result;
58 for (
const auto &elem : m_NameToMimeType)
60 if (elem.second.AppliesTo(filePath))
62 result.push_back(elem.second);
65 std::sort(result.begin(), result.end());
66 std::reverse(result.begin(), result.end());
72 std::vector<MimeType> result;
73 for (
const auto &elem : m_NameToMimeType)
75 if (elem.second.GetCategory() == category)
77 result.push_back(elem.second);
85 std::map<std::string, MimeType>::const_iterator iter = m_NameToMimeType.find(name);
86 if (iter != m_NameToMimeType.end())
93 std::vector<std::string> result;
94 for (
const auto &elem : m_NameToMimeType)
96 std::string category = elem.second.GetCategory();
97 if (!category.empty())
99 result.push_back(category);
102 std::sort(result.begin(), result.end());
103 result.erase(std::unique(result.begin(), result.end()), result.end());
109 MimeType result = this->GetMimeType(reference);
112 std::string name = result.
GetName();
113 m_NameToMimeTypes[name].insert(result);
116 m_NameToMimeType[name] = *(m_NameToMimeTypes[name].rbegin());
121 void MimeTypeProvider::ModifiedService(
const ServiceReferenceType & , TrackedType )
126 void MimeTypeProvider::RemovedService(
const ServiceReferenceType & , TrackedType mimeType)
128 std::string name = mimeType.
GetName();
129 std::set<MimeType> &mimeTypes = m_NameToMimeTypes[name];
130 mimeTypes.erase(mimeType);
131 if (mimeTypes.empty())
133 m_NameToMimeTypes.erase(name);
134 m_NameToMimeType.erase(name);
139 m_NameToMimeType[name] = *(mimeTypes.rbegin());
143 MimeType MimeTypeProvider::GetMimeType(
const ServiceReferenceType &reference)
const
150 if (mimeType != NULL)
156 if (!rankProp.
Empty())
161 result = MimeType(*mimeType, rank,
id);
US_Core_EXPORT const std::string & SERVICE_RANKING()
virtual const char * what() const override
bool UngetService(const ServiceReferenceBase &reference)
DataCollection - Class to facilitate loading/accessing structured data.
ValueType * any_cast(Any *operand)
void * GetService(const ServiceReferenceBase &reference)
virtual MimeType GetMimeTypeForName(const std::string &name) const override
std::string GetName() const
virtual std::vector< MimeType > GetMimeTypesForFile(const std::string &filePath) const override
virtual std::vector< MimeType > GetMimeTypes() const override
The MimeType class represens a registered mime-type. It is an immutable wrapper for mitk::CustomMimeT...
US_Core_EXPORT const std::string & SERVICE_ID()
virtual std::vector< std::string > GetCategories() const override
Get a sorted and unique list of mime-type categories.
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
virtual std::vector< MimeType > GetMimeTypesForCategory(const std::string &category) const override