Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
us::ServiceReference< S > Class Template Reference

#include <usServiceReference.h>

Inheritance diagram for us::ServiceReference< S >:
Collaboration diagram for us::ServiceReference< S >:

Public Types

typedef S ServiceType
 The service interface type. More...
 

Public Member Functions

 ServiceReference ()
 Creates an invalid ServiceReference object. You can use this object in boolean expressions and it will evaluate to false. More...
 
 ServiceReference (const ServiceReferenceBase &base)
 Constructs a ServiceReference from a ServiceReferenceBase. More...
 
 ServiceReference (const ServiceReference &)=default
 
ServiceReference & operator= (const ServiceReference &)=default
 
ServiceReferenceBase & operator= (int null)
 Releases any resources held or locked by this ServiceReferenceBase and renders it invalid. More...
 
ServiceReferenceBase & operator= (const ServiceReferenceBase &reference)
 Copy assignment operator. More...
 
- Public Member Functions inherited from us::ServiceReferenceBase
 ServiceReferenceBase (const ServiceReferenceBase &ref)
 Copy constructor. More...
 
 operator bool_type () const
 Converts this ServiceReferenceBase instance into a boolean expression. If this instance was default constructed or the service it references has been unregistered, the conversion returns false, otherwise it returns true. More...
 
ServiceReferenceBase & operator= (int null)
 Releases any resources held or locked by this ServiceReferenceBase and renders it invalid. More...
 
 ~ServiceReferenceBase ()
 Destructor. More...
 
Any GetProperty (const std::string &key) const
 Returns the property value to which the specified property key is mapped in the properties ServiceProperties object of the service referenced by this ServiceReferenceBase object. More...
 
void GetPropertyKeys (std::vector< std::string > &keys) const
 Returns a list of the keys in the ServiceProperties object of the service referenced by this ServiceReferenceBase object. More...
 
Module * GetModule () const
 Returns the module that registered the service referenced by this ServiceReferenceBase object. More...
 
void GetUsingModules (std::vector< Module * > &modules) const
 Returns the modules that are using the service referenced by this ServiceReferenceBase object. Specifically, this method returns the modules whose usage count for that service is greater than zero. More...
 
std::string GetInterfaceId () const
 Returns the interface identifier this ServiceReferenceBase object is bound to. More...
 
bool IsConvertibleTo (const std::string &interfaceid) const
 Checks whether this ServiceReferenceBase object can be converted to another ServiceReferenceBase object, which will be bound to the given interface identifier. More...
 
bool operator< (const ServiceReferenceBase &reference) const
 Compares this ServiceReferenceBase with the specified ServiceReferenceBase for order. More...
 
bool operator== (const ServiceReferenceBase &reference) const
 Equality comparison operator. More...
 
bool operator== (std::nullptr_t) const noexcept
 Equality comparison with nullptr. More...
 
ServiceReferenceBase & operator= (const ServiceReferenceBase &reference)
 Copy assignment operator. More...
 

Detailed Description

template<class S>
class us::ServiceReference< S >

A reference to a service.

The framework returns ServiceReference objects from the ModuleContext::GetServiceReference and ModuleContext::GetServiceReferences methods.

A ServiceReference object may be shared between modules and can be used to examine the properties of the service and to get the service object.

Every service registered in the framework has a unique ServiceRegistration object and may have multiple, distinct ServiceReference objects referring to it. ServiceReference objects associated with a ServiceRegistration are considered equal (more specifically, their operator==() method will return true when compared).

If the same service object is registered multiple times, ServiceReference objects associated with different ServiceRegistration objects are not equal.

Template Parameters
SThe class type of the service interface
See also
ModuleContext::GetServiceReference
ModuleContext::GetServiceReferences
ModuleContext::GetService
Remarks
This class is thread safe.

Definition at line 54 of file usServiceReference.h.

Member Typedef Documentation

◆ ServiceType

template<class S >
typedef S us::ServiceReference< S >::ServiceType

The service interface type.

Definition at line 59 of file usServiceReference.h.

Constructor & Destructor Documentation

◆ ServiceReference() [1/3]

template<class S >
us::ServiceReference< S >::ServiceReference ( )
inline

Creates an invalid ServiceReference object. You can use this object in boolean expressions and it will evaluate to false.

Definition at line 66 of file usServiceReference.h.

◆ ServiceReference() [2/3]

template<class S >
us::ServiceReference< S >::ServiceReference ( const ServiceReferenceBase &  base)
inline

Constructs a ServiceReference from a ServiceReferenceBase.

If the base reference is not convertible to this service interface type, the resulting ServiceReference will be invalid.

Parameters
[in]baseThe base service reference to convert.

Definition at line 78 of file usServiceReference.h.

References us::ServiceReferenceBase::GetInterfaceId(), us::ServiceReferenceBase::IsConvertibleTo(), and us::ServiceReference< S >::operator=().

◆ ServiceReference() [3/3]

template<class S >
us::ServiceReference< S >::ServiceReference ( const ServiceReference< S > &  )
default

Member Function Documentation

◆ operator=() [1/3]

template<class S >
ServiceReference& us::ServiceReference< S >::operator= ( const ServiceReference< S > &  )
default

◆ operator=() [2/3]

template<class S >
ServiceReferenceBase& us::ServiceReferenceBase::operator=

Copy assignment operator.

◆ operator=() [3/3]

template<class S >
ServiceReferenceBase& us::ServiceReferenceBase::operator=

Releases any resources held or locked by this ServiceReferenceBase and renders it invalid.

Referenced by us::ServiceReference< S >::ServiceReference().


The documentation for this class was generated from the following files: