Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
usGetModuleContext.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 (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 
13 
14 #ifndef USGETMODULECONTEXT_H
15 #define USGETMODULECONTEXT_H
16 
17 #ifndef US_MODULE_NAME
18 #error Missing preprocessor define US_MODULE_NAME
19 #endif
20 
21 #include <usGlobalConfig.h>
22 #include <usModuleRegistry.h>
23 #include <usModule.h>
24 #include <mitkLog.h>
25 #include <usModuleUtils_p.h>
26 
27 namespace us {
28 
29 class ModuleContext;
30 
42 {
43  Module* module = ModuleRegistry::GetModule(US_STR(US_MODULE_NAME));
44  if (module)
45  {
46  return module->GetModuleContext();
47  }
48  MITK_WARN << "Module '" << US_STR(US_MODULE_NAME) << "' unknown. "
49  "The calling module probably misses a US_MODULE_NAME compile definition "
50  "and/or a call to US_INITIALIZE_MODULE in one of its source files.";
51  return nullptr;
52 }
53 
54 }
55 
56 #endif // USGETMODULECONTEXT_H
static Module * GetModule(long id)
Get the module that has the specified module identifier.
Represents a CppMicroServices module.
Definition: usModule.h:70
ModuleContext * GetModuleContext() const
Returns this module's ModuleContext. The returned ModuleContext can be used by the caller to act on b...
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
#define MITK_WARN
Log a warning message.
Definition: mitkLog.h:365