Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
mitkPreferenceListReaderOptionsFunctor.cpp
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 
14 
16 {
17 
18 }
19 
21 {
22 
23 }
24 
26 {
27  auto readerItems = loadInfo.m_ReaderSelector.Get();
28 
29  auto selectedID = loadInfo.m_ReaderSelector.GetSelectedId();
30 
31  //check if the pre selected ID is on the blacklist. If true, "un"select.
32  auto finding = std::find(m_BlackList.begin(), m_BlackList.end(), loadInfo.m_ReaderSelector.GetSelected().GetDescription());
33  if (finding != m_BlackList.end())
34  {
35  selectedID = -1;
36  }
37 
38  for (auto reader : readerItems)
39  {
40  finding = std::find(m_BlackList.begin(), m_BlackList.end(), reader.GetDescription());
41 
42  if (finding != m_BlackList.end())
43  {
44  continue;
45  }
46 
47  finding = std::find(m_PreferenceList.begin(), m_PreferenceList.end(), reader.GetDescription());
48 
49  if (finding != m_PreferenceList.end())
50  {
51  selectedID = reader.GetServiceId();
52  break;
53  }
54 
55  if (selectedID==-1)
56  {
57  selectedID = reader.GetServiceId();
58  }
59  }
60 
61  if (selectedID == -1)
62  {
63  mitkThrow() << "No valid reader found. All available readers are black listed.";
64  }
65 
66  if (!loadInfo.m_ReaderSelector.Select(selectedID))
67  {
68  MITK_DEBUG << "Was not able to select reader found by the PreferenceListReaderOptionsFunctor";
69  }
70 
71  return true;
72 }
#define MITK_DEBUG
Definition: mitkLogMacros.h:22
std::vector< Item > Get() const
Get a sorted list of file reader items.
#define mitkThrow()
FileReaderSelector m_ReaderSelector
Definition: mitkIOUtil.h:57
bool operator()(IOUtil::LoadInfo &loadInfo) const override