Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkPythonActivator.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 mitkPythonActivator_h
17 #define mitkPythonActivator_h
18 
19 // Microservices
20 #include <usModuleActivator.h>
21 #include "usModuleContext.h"
22 #include "mitkPythonService.h"
23 #include <usServiceRegistration.h>
24 
25 namespace mitk
26 {
31  class PythonActivator : public us::ModuleActivator
32  {
33  public:
34 
35  void Load(us::ModuleContext* context)
36  {
37  MITK_DEBUG << "PythonActivator::Load";
38  // Registering PythonService as MicroService
39  m_PythonService = itk::SmartPointer<mitk::PythonService>(new PythonService());
40 
41  us::ServiceProperties _PythonServiceProps;
42  _PythonServiceProps["Name"] = std::string("PythonService");
43 
44  m_PythonServiceRegistration = context->RegisterService<mitk::IPythonService>(m_PythonService.GetPointer(), _PythonServiceProps);
45  }
46 
47  void Unload(us::ModuleContext* context)
48  {
49  MITK_DEBUG("PythonActivator") << "PythonActivator::Unload";
50  MITK_DEBUG("PythonActivator") << "m_PythonService GetReferenceCount " << m_PythonService->GetReferenceCount();
51  m_PythonServiceRegistration.Unregister();
52  m_PythonService->Delete();
53  MITK_DEBUG("PythonActivator") << "m_PythonService GetReferenceCount " << m_PythonService->GetReferenceCount();
54  }
55 
56  virtual ~PythonActivator()
57  {
58  }
59 
60  private:
62  us::ServiceRegistration<PythonService> m_PythonServiceRegistration;
63  };
64 }
65 
66 US_EXPORT_MODULE_ACTIVATOR(mitk::PythonActivator)
67 #endif
#define MITK_DEBUG
Definition: mitkLogMacros.h:26
DataCollection - Class to facilitate loading/accessing structured data.
US_UNORDERED_MAP_TYPE< std::string, Any > ServiceProperties
US_EXPORT_MODULE_ACTIVATOR(mitk::SimulationActivator)