Medical Imaging Interaction Toolkit  2018.4.99-87d68d9f
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 (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 //Microservices
18 #include <usGetModuleContext.h>
19 #include <usModuleContext.h>
20 
21 
23  : m_ServiceRegistration()
24  , m_TrackingDeviceTypeInformations()
25 {
26 }
27 
29 {
30  std::vector<TrackingDeviceTypeInformation*>::iterator iter = m_TrackingDeviceTypeInformations.begin();
31 
32  for (; iter != m_TrackingDeviceTypeInformations.end(); iter++)
33  {
34  delete (*iter);
35  }
36 
37  m_TrackingDeviceTypeInformations.clear();
38 }
39 
41 {
42  us::ModuleContext* context = us::GetModuleContext();
43 
44  m_ServiceRegistration = context->RegisterService(this);
45 }
46 
48 {
49  if (m_ServiceRegistration != nullptr) m_ServiceRegistration.Unregister();
50  m_ServiceRegistration = 0;
51 }
52 
54 {
55  if (typeInformation != nullptr)
56  {
57  m_TrackingDeviceTypeInformations.push_back(typeInformation);
58  }
59 }
60 
62 {
63  for (auto deviceType : m_TrackingDeviceTypeInformations)
64  {
65  if (deviceType->GetTrackingDeviceName() == type)
66  {
67  return deviceType;
68  }
69  }
70 
71  return nullptr;
72 }
73 
75 {
76  for (auto deviceType : m_TrackingDeviceTypeInformations)
77  {
78  if (deviceType->GetTrackingDeviceName() == type)
79  {
80  return deviceType->m_TrackingDeviceData;
81  }
82  }
83 
84  return std::vector<TrackingDeviceData>();
85 }
86 
88 {
89  if (GetDeviceDataForLine(type).empty())
90  {
92  }
93 
94  return GetDeviceDataForLine(type).front();
95 }
96 
98 {
99  for (auto deviceType : m_TrackingDeviceTypeInformations)
100  {
101  for (auto deviceData : deviceType->m_TrackingDeviceData)
102  {
103  if (deviceData.Model == modelName)
104  {
105  return deviceData;
106  }
107  }
108  }
109 
111 }
112 
114 {
115  std::vector<std::string> names;
116  for (auto deviceType : m_TrackingDeviceTypeInformations)
117  {
118  names.push_back(deviceType->GetTrackingDeviceName());
119  }
120  return names;
121 }
TrackingDeviceData GetDeviceDataByName(const std::string &modelName)
std::vector< TrackingDeviceData > GetDeviceDataForLine(TrackingDeviceType type)
std::string modelName
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...