Medical Imaging Interaction Toolkit  2018.4.99-9a29ffc6
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 (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 __mitkKinectActivator_h
13 #define __mitkKinectActivator_h
14 
15 // Microservices
16 #include <usServiceRegistration.h>
17 #include <usModuleActivator.h>
18 #include <usModuleContext.h>
19 
20 //ToF
21 #include "mitkIToFDeviceFactory.h"
22 #include "mitkToFConfig.h"
25 
26 namespace mitk
27 {
32 class KinectActivator : public us::ModuleActivator{
33 public:
38  void Load(us::ModuleContext* context)
39  {
40  //Implementing KinectDeviceFactory
41  KinectDeviceFactory* kinectFactory = new KinectDeviceFactory();
42  us::ServiceProperties kinectFactoryProps;
43  kinectFactoryProps["ToFFactoryName"] =kinectFactory->GetFactoryName();
44  context->RegisterService<IToFDeviceFactory>(kinectFactory, kinectFactoryProps);
45  kinectFactory->ConnectToFDevice();
46 
47  m_Factories.push_back( kinectFactory );
48  }
49 
53  void Unload(us::ModuleContext* )
54  {
55  }
56 
61  ~KinectActivator()
62  {
63  if(m_Factories.size() > 0)
64  {
65  for(std::list< IToFDeviceFactory* >::iterator it = m_Factories.begin(); it != m_Factories.end(); ++it)
66  {
67  delete (*it);
68  }
69  }
70  }
71 
72 private:
76  std::list< IToFDeviceFactory* > m_Factories;
77 
78 };
79 }
80 US_EXPORT_MODULE_ACTIVATOR(mitk::KinectActivator)
81 #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.