Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
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 #ifndef __mitkToFCameraPMDModuleActivator_h
17 #define __mitkToFCameraPMDModuleActivator_h
18 
19 // Microservices
20 #include <usServiceRegistration.h>
21 #include <usModuleContext.h>
22 #include <usModuleActivator.h>
23 
24 //ToF
25 #include "mitkIToFDeviceFactory.h"
26 #include "mitkToFConfig.h"
27 #include "mitkToFPMDConfig.h"
30 
31 //The follwing heades only get implemented if the respective Devices are activated through Cmake
32 #ifdef MITK_USE_TOF_PMDCAMCUBE
35 #endif
36 
37 #ifdef MITK_USE_TOF_PMDO3
39 #endif
40 
41 #ifdef MITK_USE_TOF_PMDCAMBOARD
44 #endif
45 
46 namespace mitk
47 {
52 class PMDModuleActivator : public us::ModuleActivator {
53 public:
54 
59  void Load(us::ModuleContext* context)
60  {
61  //The PMD CamBoard-Factory gets activated as soon as the user toggels one the PMD-parameter in Cmake to on
62 #ifdef MITK_USE_TOF_PMDCAMCUBE
63  //Register Cam Cube Factory
64  ToFCameraPMDCamCubeDeviceFactory* toFCameraPMDCamCubeDeviceFactory = new ToFCameraPMDCamCubeDeviceFactory();
65  us::ServiceProperties camCubeFactoryProps;
66  camCubeFactoryProps["ToFFactoryName"] = toFCameraPMDCamCubeDeviceFactory->GetFactoryName();
67  context->RegisterService<IToFDeviceFactory>(toFCameraPMDCamCubeDeviceFactory,camCubeFactoryProps);
68 
69  toFCameraPMDCamCubeDeviceFactory->ConnectToFDevice();
70 
71  //Register PMD Raw Data Cam Cube DeviceFactory
72  ToFCameraPMDRawDataCamCubeDeviceFactory* toFCameraPMDRawDataCamCubeDeviceFactory = new ToFCameraPMDRawDataCamCubeDeviceFactory();
73  us::ServiceProperties rawCamCubeFactoryProps;
74  rawCamCubeFactoryProps["ToFFactoryName"] = toFCameraPMDRawDataCamCubeDeviceFactory->GetFactoryName();
75  context->RegisterService<IToFDeviceFactory>(toFCameraPMDRawDataCamCubeDeviceFactory,rawCamCubeFactoryProps);
76 
77  toFCameraPMDRawDataCamCubeDeviceFactory->ConnectToFDevice();
78 
79  m_Factories.push_back(toFCameraPMDCamCubeDeviceFactory);
80  m_Factories.push_back(toFCameraPMDRawDataCamCubeDeviceFactory);
81 #endif
82 
83  //The PMD O3-Factory gets activated as soon as the user toggels one the PMD-parameter in Cmake to on
84 #ifdef MITK_USE_TOF_PMDO3
85  //Implementing PMD O3D DeviceFactory
86  ToFCameraPMDO3DeviceFactory* toFCameraPMDO3DeviceFactory = new ToFCameraPMDO3DeviceFactory();
87  us::ServiceProperties o3FactoryProps;
88  o3FactoryProps["ToFFactoryName"] = toFCameraPMDO3DeviceFactory->GetFactoryName();
89  context->RegisterService<IToFDeviceFactory>(toFCameraPMDO3DeviceFactory,o3FactoryProps);
90 
91  toFCameraPMDO3DeviceFactory->ConnectToFDevice();
92 
93  m_Factories.push_back(toFCameraPMDO3DeviceFactory);
94 #endif
95 
96  //The PMD CamBoard-Factory gets activated as soon as the user toggels one the PMD-parameter in Cmake to on
97 #ifdef MITK_USE_TOF_PMDCAMBOARD
98  //Implementing CamBoardDeviceFactory
99  ToFCameraPMDCamBoardDeviceFactory* toFCameraPMDCamBoardDeviceFactory = new ToFCameraPMDCamBoardDeviceFactory();
100  us::ServiceProperties camBoardFactoryProps;
101  camBoardFactoryProps["ToFFactoryName"] = toFCameraPMDCamBoardDeviceFactory->GetFactoryName();
102  context->RegisterService<IToFDeviceFactory>(toFCameraPMDCamBoardDeviceFactory, camBoardFactoryProps);
103 
104  toFCameraPMDCamBoardDeviceFactory->ConnectToFDevice();
105 
106 
107  //Implementing PMD Raw Data Cam Board DeviceFactory
108  ToFCameraPMDRawDataCamBoardDeviceFactory* toFCameraPMDRawDataCamBoardDeviceFactory = new ToFCameraPMDRawDataCamBoardDeviceFactory();
109  us::ServiceProperties rawCamBoardFactoryProps;
110  rawCamBoardFactoryProps["ToFFactoryName"] = toFCameraPMDRawDataCamBoardDeviceFactory->GetFactoryName();
111  context->RegisterService<IToFDeviceFactory>(toFCameraPMDRawDataCamBoardDeviceFactory,rawCamBoardFactoryProps);
112 
113  toFCameraPMDRawDataCamBoardDeviceFactory->ConnectToFDevice();
114 
115  m_Factories.push_back(toFCameraPMDCamBoardDeviceFactory);
116  m_Factories.push_back(toFCameraPMDRawDataCamBoardDeviceFactory);
117 #endif
118 
119  //The PMD Player Device Factory gets activated as soon as the user toggels one of the PMD-parameters in Cmake to on
120  //Registrating the PMD Player DeviceFactory
121  ToFCameraPMDPlayerDeviceFactory* toFCameraPMDPlayerDeviceFactory = new ToFCameraPMDPlayerDeviceFactory();
122  us::ServiceProperties pMDPlayerFactoryProps;
123  pMDPlayerFactoryProps["ToFFactoryName"] = toFCameraPMDPlayerDeviceFactory->GetFactoryName();
124  context->RegisterService<IToFDeviceFactory>(toFCameraPMDPlayerDeviceFactory,pMDPlayerFactoryProps);
125 
126  toFCameraPMDPlayerDeviceFactory->ConnectToFDevice();
127 
128  m_Factories.push_back(toFCameraPMDPlayerDeviceFactory);
129 
130  }
131 
135  void Unload(us::ModuleContext* )
136  {
137  }
138 
142  ~PMDModuleActivator()
143  {
144  if(m_Factories.size() > 0)
145  {
146  for(std::list< IToFDeviceFactory* >::iterator it = m_Factories.begin(); it != m_Factories.end(); ++it)
147  {
148  delete (*it);
149  }
150  }
151  }
152 
153 private:
157  std::list< IToFDeviceFactory* > m_Factories;
158 
159 };
160 }
161 US_EXPORT_MODULE_ACTIVATOR(mitk::PMDModuleActivator)
162 #endif
DataCollection - Class to facilitate loading/accessing structured data.
US_UNORDERED_MAP_TYPE< std::string, Any > ServiceProperties
US_EXPORT_MODULE_ACTIVATOR(mitk::SimulationActivator)