Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkToFHardwareActivator.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 __mitkToFHardwareModuleActivator_h
17 #define __mitkToFHardwareModuleActivator_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 
29 /*
30  * This is the module activator for the "ToFHardware" module. It registers services
31  * like the IToFDeviceFactory.
32 */
33 
34 namespace mitk
35 {
36 class ToFHardwareActivator : public us::ModuleActivator {
37 public:
38 
39  void Load(us::ModuleContext* context) override
40  {
41  //Registering MITKPlayerDevice as MicroService
42  ToFCameraMITKPlayerDeviceFactory* toFCameraMITKPlayerDeviceFactory = new ToFCameraMITKPlayerDeviceFactory();
43  us::ServiceProperties mitkPlayerFactoryProps;
44  mitkPlayerFactoryProps["ToFFactoryName"] = toFCameraMITKPlayerDeviceFactory->GetFactoryName();
45  context->RegisterService<IToFDeviceFactory>(toFCameraMITKPlayerDeviceFactory, mitkPlayerFactoryProps);
46  //Create an instance of the player
47  toFCameraMITKPlayerDeviceFactory->ConnectToFDevice();
48 
49  m_Factories.push_back( toFCameraMITKPlayerDeviceFactory );
50  }
51 
52  void Unload(us::ModuleContext* ) override
53  {
54  }
55 
56  ~ToFHardwareActivator()
57  {
58  if(m_Factories.size() > 0)
59  {
60  for(std::list< IToFDeviceFactory* >::iterator it = m_Factories.begin(); it != m_Factories.end(); ++it)
61  {
62  delete (*it);
63  }
64  }
65  }
66 
67 private:
68 
69  std::list< IToFDeviceFactory* > m_Factories;
70 
71 };
72 }
73 US_EXPORT_MODULE_ACTIVATOR(mitk::ToFHardwareActivator)
74 #endif
DataCollection - Class to facilitate loading/accessing structured data.
US_UNORDERED_MAP_TYPE< std::string, Any > ServiceProperties
US_EXPORT_MODULE_ACTIVATOR(mitk::SimulationActivator)