Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
usServiceReference.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 USSERVICEREFERENCE_H
14 #define USSERVICEREFERENCE_H
15 
16 #include <usServiceInterface.h>
17 #include <usServiceReferenceBase.h>
18 
19 namespace us {
20 
53 template<class S>
55 
56 public:
57 
59  typedef S ServiceType;
60 
67  {
68  }
69 
79  : ServiceReferenceBase(base)
80  {
81  const std::string interfaceId(us_service_interface_iid<S>());
82  if (GetInterfaceId() != interfaceId)
83  {
84  if (this->IsConvertibleTo(interfaceId))
85  {
86  this->SetInterfaceId(interfaceId);
87  }
88  else
89  {
90  this->operator =(0);
91  }
92  }
93  }
94 
97 
98  using ServiceReferenceBase::operator=;
99 
100 };
101 
109 template<>
110 class ServiceReference<void> : public ServiceReferenceBase
111 {
112 
113 public:
114 
121  {
122  }
123 
129  ServiceReference(const ServiceReferenceBase& base)
130  : ServiceReferenceBase(base)
131  {
132  }
133 
134  ServiceReference(const ServiceReference&) = default;
135  ServiceReference& operator=(const ServiceReference&) = default;
136 
137  using ServiceReferenceBase::operator=;
138 
140  typedef void ServiceType;
141 };
142 
150 typedef ServiceReference<void> ServiceReferenceU;
151 
152 }
153 
154 #endif // USSERVICEREFERENCE_H
bool IsConvertibleTo(const std::string &interfaceid) const
Checks whether this ServiceReferenceBase object can be converted to another ServiceReferenceBase obje...
std::string GetInterfaceId() const
Returns the interface identifier this ServiceReferenceBase object is bound to.
ServiceReference()
Creates an invalid ServiceReference object. You can use this object in boolean expressions and it wil...
S ServiceType
The service interface type.
ServiceReference(const ServiceReference &)=default
ServiceReference & operator=(const ServiceReference &)=default
ServiceReference(const ServiceReferenceBase &base)
Constructs a ServiceReference from a ServiceReferenceBase.
ServiceReferenceBase & operator=(int null)
Releases any resources held or locked by this ServiceReferenceBase and renders it invalid.
ServiceReference< void > ServiceReferenceU
Definition: usModule.h:31