Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
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 (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 __mitkToFHardwareModuleActivator_h
13 #define __mitkToFHardwareModuleActivator_h
14 
15 // Microservices
16 #include <usServiceRegistration.h>
17 #include <usModuleActivator.h>
18 #include <usModuleContext.h>
19 
20 #include "mitkIToFDeviceFactory.h"
21 
22 #include "mitkToFConfig.h"
24 
25 /*
26  * This is the module activator for the "ToFHardware" module. It registers services
27  * like the IToFDeviceFactory.
28 */
29 
30 namespace mitk
31 {
32 class ToFHardwareActivator : public us::ModuleActivator {
33 public:
34 
35  void Load(us::ModuleContext* context) override
36  {
37  //Registering MITKPlayerDevice as MicroService
38  ToFCameraMITKPlayerDeviceFactory* toFCameraMITKPlayerDeviceFactory = new ToFCameraMITKPlayerDeviceFactory();
39  us::ServiceProperties mitkPlayerFactoryProps;
40  mitkPlayerFactoryProps["ToFFactoryName"] = toFCameraMITKPlayerDeviceFactory->GetFactoryName();
41  context->RegisterService<IToFDeviceFactory>(toFCameraMITKPlayerDeviceFactory, mitkPlayerFactoryProps);
42  //Create an instance of the player
43  toFCameraMITKPlayerDeviceFactory->ConnectToFDevice();
44 
45  m_Factories.push_back( toFCameraMITKPlayerDeviceFactory );
46  }
47 
48  void Unload(us::ModuleContext* ) override
49  {
50  }
51 
52  ~ToFHardwareActivator() override
53  {
54  if(m_Factories.size() > 0)
55  {
56  for(std::list< IToFDeviceFactory* >::iterator it = m_Factories.begin(); it != m_Factories.end(); ++it)
57  {
58  delete (*it);
59  }
60  }
61  }
62 
63 private:
64 
65  std::list< IToFDeviceFactory* > m_Factories;
66 
67 };
68 }
69 US_EXPORT_MODULE_ACTIVATOR(mitk::ToFHardwareActivator)
70 #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.