Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkCoreServices.h
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 
17 #ifndef MITKCORESERVICES_H
18 #define MITKCORESERVICES_H
19 
20 #include "MitkCoreExports.h"
21 
22 #include <mitkCommon.h>
23 #include <mitkLogMacros.h>
24 
25 #include <mitkServiceInterface.h>
26 #include <usGetModuleContext.h>
27 #include <usModuleContext.h>
28 #include <usServiceReference.h>
29 
30 #include <cassert>
31 
32 namespace mitk
33 {
34  struct IMimeTypeProvider;
35  struct IShaderRepository;
36  class IPropertyAliases;
37  class IPropertyDescriptions;
38  class IPropertyExtensions;
39  class IPropertyFilters;
40  class IPropertyPersistence;
41 
61  {
62  public:
68  static IShaderRepository *GetShaderRepository();
69 
75  static IPropertyAliases *GetPropertyAliases(us::ModuleContext *context = us::GetModuleContext());
76 
82  static IPropertyDescriptions *GetPropertyDescriptions(us::ModuleContext *context = us::GetModuleContext());
83 
89  static IPropertyExtensions *GetPropertyExtensions(us::ModuleContext *context = us::GetModuleContext());
90 
96  static IPropertyFilters *GetPropertyFilters(us::ModuleContext *context = us::GetModuleContext());
97 
103  static IPropertyPersistence *GetPropertyPersistence(us::ModuleContext *context = us::GetModuleContext());
104 
110  static IMimeTypeProvider *GetMimeTypeProvider(us::ModuleContext *context = us::GetModuleContext());
111 
117  template <class S>
118  static bool Unget(S *service, us::ModuleContext *context = us::GetModuleContext())
119  {
120  return Unget(context, us_service_interface_iid<S>(), service);
121  }
122 
123  private:
124  static bool Unget(us::ModuleContext *context, const std::string &interfaceId, void *service);
125 
126  // purposely not implemented
127  CoreServices();
128  CoreServices(const CoreServices &);
129  CoreServices &operator=(const CoreServices &);
130  };
131 
142  template <class S>
144  {
145  public:
146  explicit CoreServicePointer(S *service) : m_service(service) { assert(m_service); }
148  {
149  try
150  {
151  CoreServices::Unget(m_service);
152  }
153  catch (const std::exception &e)
154  {
155  MITK_ERROR << e.what();
156  }
157  catch (...)
158  {
159  MITK_ERROR << "Ungetting core service failed.";
160  }
161  }
162 
163  S *operator->() const { return m_service; }
164  private:
165  // purposely not implemented
167  CoreServicePointer &operator=(const CoreServicePointer &);
168 
169  S *const m_service;
170  };
171 }
172 
173 #endif // MITKCORESERVICES_H
Interface of property aliases service.
#define MITKCORE_EXPORT
#define MITK_ERROR
Definition: mitkLogMacros.h:24
Access MITK core services.
DataCollection - Class to facilitate loading/accessing structured data.
Interface of property extensions service.
Interface of property descriptions service.
Management class for vtkShader XML descriptions.
#define MITK_LOCAL
Definition: mitkCommon.h:201
The IMimeTypeProvider service interface allows to query all registered mime types.
Interface of property persistence service.
A RAII helper class for core service objects.
Interface of property filters service.
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
static bool Unget(S *service, us::ModuleContext *context=us::GetModuleContext())
Unget a previously acquired service instance.