MCPcopy Create free account
hub / github.com/MITK/MITK / operator()

Method operator()

Modules/Core/src/IO/mitkPreferenceListReaderOptionsFunctor.cpp:35–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35bool mitk::PreferenceListReaderOptionsFunctor::operator()(IOUtil::LoadInfo &loadInfo) const
36{
37 auto readerItems = loadInfo.m_ReaderSelector.Get();
38
39 auto selectedID = loadInfo.m_ReaderSelector.GetSelectedId();
40
41 //check if the pre selected ID is on the blacklist. If true, "un"select.
42 auto finding = std::find(m_BlackList.begin(), m_BlackList.end(), loadInfo.m_ReaderSelector.GetSelected().GetDescription());
43 if (finding != m_BlackList.end())
44 {
45 selectedID = -1;
46 }
47
48 for (const auto &reader : readerItems)
49 {
50 finding = std::find(m_BlackList.begin(), m_BlackList.end(), reader.GetDescription());
51
52 if (finding != m_BlackList.end())
53 {
54 continue;
55 }
56
57 finding = std::find(m_PreferenceList.begin(), m_PreferenceList.end(), reader.GetDescription());
58
59 if (finding != m_PreferenceList.end())
60 {
61 selectedID = reader.GetServiceId();
62 break;
63 }
64
65 if (selectedID==-1)
66 {
67 selectedID = reader.GetServiceId();
68 }
69 }
70
71 if (selectedID == -1)
72 {
73 mitkThrow() << "No valid reader found. All available readers are black listed.";
74 }
75
76 if (!loadInfo.m_ReaderSelector.Select(selectedID))
77 {
78 MITK_DEBUG << "Was not able to select reader found by the PreferenceListReaderOptionsFunctor";
79 }
80
81 auto reader = loadInfo.m_ReaderSelector.GetSelected().GetReader();
82 if (!m_Options.empty() && nullptr != reader)
83 {
84 reader->SetOptions(m_Options);
85 }
86
87 return true;
88}

Callers

nothing calls this directly

Calls 11

GetMethod · 0.45
GetSelectedIdMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetDescriptionMethod · 0.45
GetSelectedMethod · 0.45
GetServiceIdMethod · 0.45
SelectMethod · 0.45
GetReaderMethod · 0.45
emptyMethod · 0.45
SetOptionsMethod · 0.45

Tested by

no test coverage detected