36 for (
auto &elem : m_ServiceObjects)
38 elem.second.UngetService(elem.first);
45 return GetReferences(baseData, std::string(), context);
49 const mitk::BaseData *baseData,
const std::string &mimeType, us::ModuleContext *context)
53 mitkThrow() <<
"FileWriterRegistry::GetReferences was called with null basedata.";
54 std::vector<mitk::FileWriterRegistry::WriterReference> emptyResult;
61 std::vector<WriterReference> result;
66 for (std::vector<std::string>::const_iterator clIter = classHierarchy.begin(), clIterEnd = classHierarchy.end();
74 std::vector<WriterReference> refs = context->GetServiceReferences<
IFileWriter>(filter);
75 result.insert(result.end(), refs.begin(), refs.end());
81 us::ModuleContext *context)
91 m_ServiceObjects.insert(std::make_pair(writer, serviceObjects));
96 const std::string &mimeType,
97 us::ModuleContext *context)
101 mitkThrow() <<
"FileWriterRegistry::GetReferences was called with null basedata.";
102 std::vector<mitk::IFileWriter *> emptyResult;
109 std::vector<mitk::IFileWriter *> result;
111 std::vector<us::ServiceReference<IFileWriter>> refs;
112 if (mimeType.empty())
114 refs = GetReferences(baseData, context);
118 refs = GetReferences(baseData, mimeType, context);
120 std::sort(refs.begin(), refs.end());
122 result.reserve(refs.size());
131 m_ServiceObjects.insert(std::make_pair(writer, serviceObjects));
132 result.push_back(writer);
140 std::map<mitk::IFileWriter *, us::ServiceObjects<mitk::IFileWriter>>::iterator writerIter =
141 m_ServiceObjects.find(writer);
142 if (writerIter != m_ServiceObjects.end())
144 writerIter->second.UngetService(writer);
145 m_ServiceObjects.erase(writerIter);
151 for (
const auto &writer : writers)
153 this->UngetWriter(writer);
void UngetWriter(IFileWriter *writer)
Base of all data objects.
std::vector< IFileWriter * > GetWriters(const BaseData *baseData, const std::string &mimeType, us::ModuleContext *context=us::GetModuleContext())
static std::string PROP_MIMETYPE()
Service property name for the mime-type associated with this file writer.
virtual std::vector< std::string > GetClassHierarchy() const
IFileWriter * GetWriter(const WriterReference &ref, us::ModuleContext *context=us::GetModuleContext())
void UngetWriters(const std::vector< IFileWriter * > &writers)
static std::vector< WriterReference > GetReferences(const BaseData *baseData, us::ModuleContext *context=us::GetModuleContext())
US_Core_EXPORT const std::string & OBJECTCLASS()
static std::string PROP_BASEDATA_TYPE()
Service property name for the supported mitk::BaseData sub-class.
The common interface of all MITK file writers.
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.