Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkKinectActivator.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 __mitkKinectActivator_h
17 #define __mitkKinectActivator_h
18 
19 // Microservices
20 #include <usServiceRegistration.h>
21 #include <usModuleActivator.h>
22 #include <usModuleContext.h>
23 
24 //ToF
25 #include "mitkIToFDeviceFactory.h"
26 #include "mitkToFConfig.h"
29 
30 namespace mitk
31 {
36 class KinectActivator : public us::ModuleActivator{
37 public:
42  void Load(us::ModuleContext* context)
43  {
44  //Implementing KinectDeviceFactory
45  KinectDeviceFactory* kinectFactory = new KinectDeviceFactory();
46  us::ServiceProperties kinectFactoryProps;
47  kinectFactoryProps["ToFFactoryName"] =kinectFactory->GetFactoryName();
48  context->RegisterService<IToFDeviceFactory>(kinectFactory, kinectFactoryProps);
49  kinectFactory->ConnectToFDevice();
50 
51  m_Factories.push_back( kinectFactory );
52  }
53 
57  void Unload(us::ModuleContext* )
58  {
59  }
60 
65  ~KinectActivator()
66  {
67  if(m_Factories.size() > 0)
68  {
69  for(std::list< IToFDeviceFactory* >::iterator it = m_Factories.begin(); it != m_Factories.end(); ++it)
70  {
71  delete (*it);
72  }
73  }
74  }
75 
76 private:
80  std::list< IToFDeviceFactory* > m_Factories;
81 
82 };
83 }
84 US_EXPORT_MODULE_ACTIVATOR(mitk::KinectActivator)
85 #endif
DataCollection - Class to facilitate loading/accessing structured data.
US_UNORDERED_MAP_TYPE< std::string, Any > ServiceProperties
US_EXPORT_MODULE_ACTIVATOR(mitk::SimulationActivator)