Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkPMDModuleActivator.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 #ifndef __mitkToFCameraPMDModuleActivator_h
13 #define __mitkToFCameraPMDModuleActivator_h
14 
15 // Microservices
16 #include <usServiceRegistration.h>
17 #include <usModuleContext.h>
18 #include <usModuleActivator.h>
19 
20 //ToF
21 #include "mitkIToFDeviceFactory.h"
22 #include "mitkToFConfig.h"
23 #include "mitkToFPMDConfig.h"
26 
27 //The follwing heades only get implemented if the respective Devices are activated through Cmake
28 #ifdef MITK_USE_TOF_PMDCAMCUBE
31 #endif
32 
33 #ifdef MITK_USE_TOF_PMDO3
35 #endif
36 
37 #ifdef MITK_USE_TOF_PMDCAMBOARD
40 #endif
41 
42 namespace mitk
43 {
48 class PMDModuleActivator : public us::ModuleActivator {
49 public:
50 
55  void Load(us::ModuleContext* context)
56  {
57  //The PMD CamBoard-Factory gets activated as soon as the user toggels one the PMD-parameter in Cmake to on
58 #ifdef MITK_USE_TOF_PMDCAMCUBE
59  //Register Cam Cube Factory
60  ToFCameraPMDCamCubeDeviceFactory* toFCameraPMDCamCubeDeviceFactory = new ToFCameraPMDCamCubeDeviceFactory();
61  us::ServiceProperties camCubeFactoryProps;
62  camCubeFactoryProps["ToFFactoryName"] = toFCameraPMDCamCubeDeviceFactory->GetFactoryName();
63  context->RegisterService<IToFDeviceFactory>(toFCameraPMDCamCubeDeviceFactory,camCubeFactoryProps);
64 
65  toFCameraPMDCamCubeDeviceFactory->ConnectToFDevice();
66 
67  //Register PMD Raw Data Cam Cube DeviceFactory
68  ToFCameraPMDRawDataCamCubeDeviceFactory* toFCameraPMDRawDataCamCubeDeviceFactory = new ToFCameraPMDRawDataCamCubeDeviceFactory();
69  us::ServiceProperties rawCamCubeFactoryProps;
70  rawCamCubeFactoryProps["ToFFactoryName"] = toFCameraPMDRawDataCamCubeDeviceFactory->GetFactoryName();
71  context->RegisterService<IToFDeviceFactory>(toFCameraPMDRawDataCamCubeDeviceFactory,rawCamCubeFactoryProps);
72 
73  toFCameraPMDRawDataCamCubeDeviceFactory->ConnectToFDevice();
74 
75  m_Factories.push_back(toFCameraPMDCamCubeDeviceFactory);
76  m_Factories.push_back(toFCameraPMDRawDataCamCubeDeviceFactory);
77 #endif
78 
79  //The PMD O3-Factory gets activated as soon as the user toggels one the PMD-parameter in Cmake to on
80 #ifdef MITK_USE_TOF_PMDO3
81  //Implementing PMD O3D DeviceFactory
82  ToFCameraPMDO3DeviceFactory* toFCameraPMDO3DeviceFactory = new ToFCameraPMDO3DeviceFactory();
83  us::ServiceProperties o3FactoryProps;
84  o3FactoryProps["ToFFactoryName"] = toFCameraPMDO3DeviceFactory->GetFactoryName();
85  context->RegisterService<IToFDeviceFactory>(toFCameraPMDO3DeviceFactory,o3FactoryProps);
86 
87  toFCameraPMDO3DeviceFactory->ConnectToFDevice();
88 
89  m_Factories.push_back(toFCameraPMDO3DeviceFactory);
90 #endif
91 
92  //The PMD CamBoard-Factory gets activated as soon as the user toggels one the PMD-parameter in Cmake to on
93 #ifdef MITK_USE_TOF_PMDCAMBOARD
94  //Implementing CamBoardDeviceFactory
95  ToFCameraPMDCamBoardDeviceFactory* toFCameraPMDCamBoardDeviceFactory = new ToFCameraPMDCamBoardDeviceFactory();
96  us::ServiceProperties camBoardFactoryProps;
97  camBoardFactoryProps["ToFFactoryName"] = toFCameraPMDCamBoardDeviceFactory->GetFactoryName();
98  context->RegisterService<IToFDeviceFactory>(toFCameraPMDCamBoardDeviceFactory, camBoardFactoryProps);
99 
100  toFCameraPMDCamBoardDeviceFactory->ConnectToFDevice();
101 
102 
103  //Implementing PMD Raw Data Cam Board DeviceFactory
104  ToFCameraPMDRawDataCamBoardDeviceFactory* toFCameraPMDRawDataCamBoardDeviceFactory = new ToFCameraPMDRawDataCamBoardDeviceFactory();
105  us::ServiceProperties rawCamBoardFactoryProps;
106  rawCamBoardFactoryProps["ToFFactoryName"] = toFCameraPMDRawDataCamBoardDeviceFactory->GetFactoryName();
107  context->RegisterService<IToFDeviceFactory>(toFCameraPMDRawDataCamBoardDeviceFactory,rawCamBoardFactoryProps);
108 
109  toFCameraPMDRawDataCamBoardDeviceFactory->ConnectToFDevice();
110 
111  m_Factories.push_back(toFCameraPMDCamBoardDeviceFactory);
112  m_Factories.push_back(toFCameraPMDRawDataCamBoardDeviceFactory);
113 #endif
114 
115  //The PMD Player Device Factory gets activated as soon as the user toggels one of the PMD-parameters in Cmake to on
116  //Registrating the PMD Player DeviceFactory
117  ToFCameraPMDPlayerDeviceFactory* toFCameraPMDPlayerDeviceFactory = new ToFCameraPMDPlayerDeviceFactory();
118  us::ServiceProperties pMDPlayerFactoryProps;
119  pMDPlayerFactoryProps["ToFFactoryName"] = toFCameraPMDPlayerDeviceFactory->GetFactoryName();
120  context->RegisterService<IToFDeviceFactory>(toFCameraPMDPlayerDeviceFactory,pMDPlayerFactoryProps);
121 
122  toFCameraPMDPlayerDeviceFactory->ConnectToFDevice();
123 
124  m_Factories.push_back(toFCameraPMDPlayerDeviceFactory);
125 
126  }
127 
131  void Unload(us::ModuleContext* )
132  {
133  }
134 
138  ~PMDModuleActivator()
139  {
140  if(m_Factories.size() > 0)
141  {
142  for(std::list< IToFDeviceFactory* >::iterator it = m_Factories.begin(); it != m_Factories.end(); ++it)
143  {
144  delete (*it);
145  }
146  }
147  }
148 
149 private:
153  std::list< IToFDeviceFactory* > m_Factories;
154 
155 };
156 }
157 US_EXPORT_MODULE_ACTIVATOR(mitk::PMDModuleActivator)
158 #endif
DataCollection - Class to facilitate loading/accessing structured data.
US_UNORDERED_MAP_TYPE< std::string, Any > ServiceProperties
#define US_EXPORT_MODULE_ACTIVATOR(_activator_type)
Export a module activator class.