Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
usModuleActivator.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 #ifndef USMODULEACTIVATOR_H_
14 #define USMODULEACTIVATOR_H_
15 
16 #ifndef US_MODULE_NAME
17 #error Missing US_MODULE_NAME preprocessor define
18 #endif
19 
20 #include <usGlobalConfig.h>
21 #include <usModuleUtils_p.h>
22 
23 namespace us {
24 
25 class ModuleContext;
26 
55 {
56 
58  virtual ~ModuleActivator() {}
59 
74  virtual void Load(ModuleContext* context) = 0;
75 
91  virtual void Unload(ModuleContext* context) = 0;
92 
93 };
94 
95 }
96 
97 
111 #define US_EXPORT_MODULE_ACTIVATOR(_activator_type) \
112  extern "C" US_ABI_EXPORT us::ModuleActivator* US_CONCAT(_us_module_activator_instance_, US_MODULE_NAME) () \
113  { \
114  struct ScopedPointer \
115  { \
116  ScopedPointer(us::ModuleActivator* activator = 0) : m_Activator(activator) {} \
117  ~ScopedPointer() { delete m_Activator; } \
118  us::ModuleActivator* m_Activator; \
119  }; \
120  \
121  static ScopedPointer activatorPtr; \
122  if (activatorPtr.m_Activator == 0) activatorPtr.m_Activator = new _activator_type; \
123  return activatorPtr.m_Activator; \
124  }
125 
126 #endif /* USMODULEACTIVATOR_H_ */
Customizes the starting and stopping of a CppMicroServices module.
virtual void Unload(ModuleContext *context)=0
Called when this module is unloaded. In general, this method should undo the work that the ModuleActi...
virtual void Load(ModuleContext *context)=0
Called when this module is loaded. This method can be used to register services or to allocate any re...
virtual ~ModuleActivator()
Virtual destructor.