Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkKinectV2Activator.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 __mitkKinectV2Activator_h
17 #define __mitkKinectV2Activator_h
18 
19 // Microservices
20 #include <usServiceRegistration.h>
21 #include <usModuleActivator.h>
22 #include <usModuleContext.h>
23 
24 #include "mitkIToFDeviceFactory.h"
25 
26 #include "mitkToFConfig.h"
28 
30 
31 /*
32  * This is the module activator for the "mitkKinectV2Module" module. It registers services
33  * like the IToFDeviceFactory.
34  */
35 
36 namespace mitk
37 {
38 class KinectV2Activator : public us::ModuleActivator {
39 public:
40 
41  void Load(us::ModuleContext* context)
42  {
43  //Implementing KinectDeviceFactory
44  KinectV2DeviceFactory* KinectV2Factory = new KinectV2DeviceFactory();
45  us::ServiceProperties KinectV2FactoryProps;
46  KinectV2FactoryProps["ToFFactoryName"] =KinectV2Factory->GetFactoryName();
47  context->RegisterService<IToFDeviceFactory>(KinectV2Factory, KinectV2FactoryProps);
48  KinectV2Factory->ConnectToFDevice();
49 
50  m_Factories.push_back( KinectV2Factory );
51  }
52 
53  void Unload(us::ModuleContext* )
54  {
55  }
56 
57  ~KinectV2Activator()
58  {
59  if(m_Factories.size() > 0)
60  {
61  for(std::list< IToFDeviceFactory* >::iterator it = m_Factories.begin(); it != m_Factories.end(); ++it)
62  {
63  delete (*it);
64  }
65  }
66  }
67 
68 private:
69 
70  std::list< IToFDeviceFactory* > m_Factories;
71 
72 };
73 }
74 US_EXPORT_MODULE_ACTIVATOR(mitk::KinectV2Activator)
75 #endif
DataCollection - Class to facilitate loading/accessing structured data.
US_UNORDERED_MAP_TYPE< std::string, Any > ServiceProperties
US_EXPORT_MODULE_ACTIVATOR(mitk::SimulationActivator)