CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ctkServiceReference Class Reference

#include <Libs/PluginFramework/ctkServiceReference.h>

Public Member Functions

 ctkServiceReference ()
 
 ctkServiceReference (const ctkServiceReference &ref)
 
QSharedPointer< ctkPlugingetPlugin () const
 
QVariant getProperty (const QString &key) const
 
QStringList getPropertyKeys () const
 
QList< QSharedPointer< ctkPlugin > > getUsingPlugins () const
 
 operator bool () const
 
bool operator< (const ctkServiceReference &reference) const
 
ctkServiceReferenceoperator= (const ctkServiceReference &reference)
 
ctkServiceReferenceoperator= (int null)
 
bool operator== (const ctkServiceReference &reference) const
 
 ~ctkServiceReference ()
 

Protected Member Functions

 ctkServiceReference (ctkServiceRegistrationPrivate *reg)
 

Protected Attributes

ctkServiceReferencePrivate * d_ptr
 

Friends

class ctkLDAPSearchFilter
 
template<class S , class R , class T >
class ctkPluginAbstractTracked
 
class ctkPluginContext
 
class ctkPluginFrameworkListeners
 
class ctkPluginPrivate
 
class ctkServiceRegistrationPrivate
 
template<class S , class T >
class ctkServiceTracker
 
template<class S , class T >
class ctkServiceTrackerPrivate
 
uint CTK_PLUGINFW_EXPORT qHash (const ctkServiceReference &)
 

Detailed Description

A reference to a service.

The Framework returns ctkServiceReference objects from the ctkPluginContext::getServiceReference and ctkPluginContext::getServiceReferences methods.

A ctkServiceReference object may be shared between plugins 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 ctkServiceRegistration object and may have multiple, distinct ctkServiceReference objects referring to it. ctkServiceReference objects associated with a ctkServiceRegistration are considered equal (more specifically, their operator==() method will return true when compared).

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

See also
ctkPluginContext::getServiceReference
ctkPluginContext::getServiceReferences
ctkPluginContext::getService
Remarks
This class is thread safe.

Definition at line 68 of file ctkServiceReference.h.

Constructor & Destructor Documentation

◆ ctkServiceReference() [1/3]

ctkServiceReference::ctkServiceReference ( )

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

◆ ctkServiceReference() [2/3]

ctkServiceReference::ctkServiceReference ( const ctkServiceReference ref)

◆ ~ctkServiceReference()

ctkServiceReference::~ctkServiceReference ( )

◆ ctkServiceReference() [3/3]

ctkServiceReference::ctkServiceReference ( ctkServiceRegistrationPrivate reg)
protected

Member Function Documentation

◆ getPlugin()

QSharedPointer<ctkPlugin> ctkServiceReference::getPlugin ( ) const

Returns the plugin that registered the service referenced by this ctkServiceReference object.

This method must return 0 when the service has been unregistered. This can be used to determine if the service has been unregistered.

Returns
The plugin that registered the service referenced by this ctkServiceReference object; 0 if that service has already been unregistered.
See also
ctkPluginContext::registerService(const QStringList&, QObject* , const ctkDictionary&)

◆ getProperty()

QVariant ctkServiceReference::getProperty ( const QString &  key) const

Returns the property value to which the specified property key is mapped in the properties ctkDictionary object of the service referenced by this ctkServiceReference object.

Property keys are case-insensitive.

This method must continue to return property values after the service has been unregistered. This is so references to unregistered services can still be interrogated.

Parameters
keyThe property key.
Returns
The property value to which the key is mapped; an invalid QVariant if there is no property named after the key.

◆ getPropertyKeys()

QStringList ctkServiceReference::getPropertyKeys ( ) const

Returns a list of the keys in the ctkDictionary object of the service referenced by this ctkServiceReference object.

This method will continue to return the keys after the service has been unregistered. This is so references to unregistered services can still be interrogated.

This method is not case-preserving; this means that every key in the returned array is in lower case, which may not be the case for the corresponding key in the properties ctkDictionary that was passed to the ctkPluginContext::registerService(const QStringList&, QObject*, const ctkDictionary&) or ctkServiceRegistration::setProperties methods.

Returns
A list of property keys.

◆ getUsingPlugins()

QList<QSharedPointer<ctkPlugin> > ctkServiceReference::getUsingPlugins ( ) const

Returns the plugins that are using the service referenced by this ctkServiceReference object. Specifically, this method returns the plugins whose usage count for that service is greater than zero.

Returns
A list of plugins whose usage count for the service referenced by this ctkServiceReference object is greater than zero.

◆ operator bool()

ctkServiceReference::operator bool ( ) const

Converts this ctkServiceReference 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.

◆ operator<()

bool ctkServiceReference::operator< ( const ctkServiceReference reference) const

Compares this ctkServiceReference with the specified ctkServiceReference for order.

If this ctkServiceReference and the specified ctkServiceReference have the same service id they are equal. This ctkServiceReference is less than the specified ctkServiceReference if it has a lower service ranking and greater if it has a higher service ranking. Otherwise, if this ctkServiceReference and the specified ctkServiceReference have the same service ranking, this ctkServiceReference is less than the specified ctkServiceReference if it has a higher service id and greater if it has a lower service id.

Parameters
referenceThe ctkServiceReference to be compared.
Returns
Returns a false or true if this ctkServiceReference is less than or greater than the specified ctkServiceReference.
Exceptions
ctkInvalidArgumentExceptionIf the specified ctkServiceReference was not created by the same framework instance as this ctkServiceReference.

◆ operator=() [1/2]

ctkServiceReference& ctkServiceReference::operator= ( const ctkServiceReference reference)

◆ operator=() [2/2]

ctkServiceReference& ctkServiceReference::operator= ( int  null)

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

◆ operator==()

bool ctkServiceReference::operator== ( const ctkServiceReference reference) const

Friends And Related Function Documentation

◆ ctkLDAPSearchFilter

friend class ctkLDAPSearchFilter
friend

Definition at line 199 of file ctkServiceReference.h.

◆ ctkPluginAbstractTracked

template<class S , class R , class T >
friend class ctkPluginAbstractTracked
friend

Definition at line 206 of file ctkServiceReference.h.

◆ ctkPluginContext

friend class ctkPluginContext
friend

Definition at line 201 of file ctkServiceReference.h.

◆ ctkPluginFrameworkListeners

friend class ctkPluginFrameworkListeners
friend

Definition at line 203 of file ctkServiceReference.h.

◆ ctkPluginPrivate

friend class ctkPluginPrivate
friend

Definition at line 202 of file ctkServiceReference.h.

◆ ctkServiceRegistrationPrivate

friend class ctkServiceRegistrationPrivate
friend

Definition at line 200 of file ctkServiceReference.h.

◆ ctkServiceTracker

template<class S , class T >
friend class ctkServiceTracker
friend

Definition at line 204 of file ctkServiceReference.h.

◆ ctkServiceTrackerPrivate

template<class S , class T >
friend class ctkServiceTrackerPrivate
friend

Definition at line 205 of file ctkServiceReference.h.

◆ qHash

uint CTK_PLUGINFW_EXPORT qHash ( const ctkServiceReference )
friend

Member Data Documentation

◆ d_ptr

ctkServiceReferencePrivate* ctkServiceReference::d_ptr
protected

Definition at line 212 of file ctkServiceReference.h.


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