Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkTrackingDeviceTypeCollection.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,
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 
18 
20 
21 //Microservices
22 #include <usGetModuleContext.h>
23 #include <usModuleContext.h>
24 
25 
27  : m_ServiceRegistration()
28  , m_TrackingDeviceTypeInformations()
29 {
30 }
31 
33 {
34  std::vector<TrackingDeviceTypeInformation*>::iterator iter = m_TrackingDeviceTypeInformations.begin();
35 
36  for (; iter != m_TrackingDeviceTypeInformations.end(); iter++)
37  {
38  delete (*iter);
39  }
40 
41  m_TrackingDeviceTypeInformations.clear();
42 }
43 
45 {
46  us::ModuleContext* context = us::GetModuleContext();
47 
48  m_ServiceRegistration = context->RegisterService(this);
49 }
50 
52 {
53  if (m_ServiceRegistration != nullptr) m_ServiceRegistration.Unregister();
54  m_ServiceRegistration = 0;
55 }
56 
58 {
59  if (typeInformation != nullptr)
60  {
61  m_TrackingDeviceTypeInformations.push_back(typeInformation);
62  }
63 }
64 
66 {
67  for (auto deviceType : m_TrackingDeviceTypeInformations)
68  {
69  if (deviceType->GetTrackingDeviceName() == type)
70  {
71  return deviceType;
72  }
73  }
74 
75  return nullptr;
76 }
77 
79 {
80  for (auto deviceType : m_TrackingDeviceTypeInformations)
81  {
82  if (deviceType->GetTrackingDeviceName() == type)
83  {
84  return deviceType->m_TrackingDeviceData;
85  }
86  }
87 
88  return std::vector<TrackingDeviceData>();
89 }
90 
92 {
93  if (GetDeviceDataForLine(type).empty())
94  {
96  }
97 
98  return GetDeviceDataForLine(type).front();
99 }
100 
102 {
103  for (auto deviceType : m_TrackingDeviceTypeInformations)
104  {
105  for (auto deviceData : deviceType->m_TrackingDeviceData)
106  {
107  if (deviceData.Model == modelName)
108  {
109  return deviceData;
110  }
111  }
112  }
113 
115 }
116 
118 {
119  std::vector<std::string> names;
120  for (auto deviceType : m_TrackingDeviceTypeInformations)
121  {
122  names.push_back(deviceType->GetTrackingDeviceName());
123  }
124  return names;
125 }
TrackingDeviceData GetDeviceDataByName(const std::string &modelName)
std::vector< TrackingDeviceData > GetDeviceDataForLine(TrackingDeviceType type)
TrackingDeviceTypeInformation * GetTrackingDeviceTypeInformation(TrackingDeviceType type)
virtual void UnRegisterMicroservice()
Registers this object as a Microservice, making it available to every module and/or plugin...
TrackingDeviceData GetFirstCompatibleDeviceDataForLine(TrackingDeviceType type)
std::string TrackingDeviceType
void RegisterTrackingDeviceType(TrackingDeviceTypeInformation *typeInformation)
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
virtual void RegisterAsMicroservice()
Registers this object as a Microservice, making it available to every module and/or plugin...