Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
usServiceListenerHook.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 USSERVICELISTENERHOOK_H
14 #define USSERVICELISTENERHOOK_H
15 
16 #include <usServiceInterface.h>
17 #include <usShrinkableVector.h>
18 #include <usSharedData.h>
19 
20 #include <string>
21 
22 namespace us {
23 
24 class ModuleContext;
25 class ServiceListenerEntry;
26 
39 {
40 
41  class ListenerInfoData;
42 
50  {
53 
55  ListenerInfo(const ListenerInfo& other);
56 
59 
62 
70  bool IsNull() const;
71 
80 
89  std::string GetFilter() const;
90 
110  bool IsRemoved() const;
111 
124  bool operator==(const ListenerInfo& other) const;
125 
126  private:
127 
128  friend class ServiceListenerEntry;
129 
130  friend struct std::hash<ServiceListenerHook::ListenerInfo>;
131 
132  ListenerInfo(ListenerInfoData* data);
133 
134  ExplicitlySharedDataPointer<ListenerInfoData> d;
135  };
136 
139 
151  virtual void Added(const std::vector<ListenerInfo>& listeners) = 0;
152 
162  virtual void Removed(const std::vector<ListenerInfo>& listeners) = 0;
163 
164 };
165 
166 }
167 
168 namespace std {
169 template<> struct hash<us::ServiceListenerHook::ListenerInfo> { std::size_t operator()(const us::ServiceListenerHook::ListenerInfo& arg) const {
170  return std::hash<const us::ServiceListenerHook::ListenerInfoData*>()(arg.d.Data());
171 } };
172 }
173 
174 #endif // USSERVICELISTENERHOOK_H
#define MITKCPPMICROSERVICES_EXPORT
A pointer to explicitly shared data requiring manual detach for copy-on-write.
Definition: usSharedData.h:146
std::size_t operator()(const us::ServiceListenerHook::ListenerInfo &arg) const
Information about a Service Listener. This class describes the module which added the Service Listene...
ListenerInfo()
Default constructor. Creates an invalid ListenerInfo instance.
std::string GetFilter() const
Return the filter string with which the listener was added.
ListenerInfo & operator=(const ListenerInfo &other)
Copy assignment operator.
bool IsRemoved() const
Return the state of the listener for this addition and removal life cycle. Initially this method will...
ModuleContext * GetModuleContext() const
Return the context of the module which added the listener.
bool operator==(const ListenerInfo &other) const
Compares this ListenerInfo to another ListenerInfo. Two.
ListenerInfo(const ListenerInfo &other)
Copy constructor.
bool IsNull() const
Can be used to check if this ListenerInfo instance is valid, or if it has been constructed using the ...
Service Listener Hook Service.