Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkToolManagerProvider.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 
14 
15 // micro service includes
16 #include <usGetModuleContext.h>
17 #include <usServiceReference.h>
18 
20 {
21 }
22 
24 {
25  this->m_ToolManager = nullptr;
26 }
27 
29 {
30  return this->m_ToolManager.GetPointer();
31 }
32 
34 {
36  static us::ModuleContext *context = us::GetModuleContext();
37  if (!serviceRef)
38  {
39  // This is either the first time GetInstance() was called,
40  // or a SingletonOneService instance has not yet been registered.
41  serviceRef = context->GetServiceReference<mitk::ToolManagerProvider>();
42  }
43  if (serviceRef)
44  {
45  // We have a valid service reference. It always points to the service
46  // with the lowest id (usually the one which was registered first).
47  // This still might return a null pointer, if all SingletonOneService
48  // instances have been unregistered (during unloading of the library,
49  // for example).
50  return context->GetService<mitk::ToolManagerProvider>(serviceRef);
51  }
52  else
53  {
54  // No SingletonOneService instance was registered yet.
55  return nullptr;
56  }
57 }
DataCollection - Class to facilitate loading/accessing structured data.
virtual mitk::ToolManager * GetToolManager()
Returns ToolManager object.
mitk::ToolManager::Pointer m_ToolManager
Micro Service Singleton to get an instance of mitk::ToolManager.
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
static mitk::ToolManagerProvider * GetInstance()
Returns an instance of ToolManagerProvider service.
Manages and coordinates instances of mitk::Tool.