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 | Friends | List of all members
ctkPluginTracker< T > Class Template Reference

#include <Libs/PluginFramework/ctkPluginTracker.h>

Inheritance diagram for ctkPluginTracker< T >:
Inheritance graph
[legend]
Collaboration diagram for ctkPluginTracker< T >:
Collaboration graph
[legend]

Public Member Functions

virtual void close ()
 
 ctkPluginTracker (ctkPluginContext *context, ctkPlugin::States stateMask, ctkPluginTrackerCustomizer< T > *customizer=0)
 
virtual T getObject (QSharedPointer< ctkPlugin > plugin) const
 
virtual QList< QSharedPointer< ctkPlugin > > getPlugins () const
 
virtual QMap< QSharedPointer< ctkPlugin >, T > getTracked () const
 
virtual int getTrackingCount () const
 
virtual bool isEmpty () const
 
virtual void open ()
 
virtual void remove (QSharedPointer< ctkPlugin > plugin)
 
virtual int size () const
 
 ~ctkPluginTracker ()
 

Protected Member Functions

addingPlugin (QSharedPointer< ctkPlugin > plugin, const ctkPluginEvent &event)
 
void modifiedPlugin (QSharedPointer< ctkPlugin > plugin, const ctkPluginEvent &event, T object)
 
void removedPlugin (QSharedPointer< ctkPlugin > plugin, const ctkPluginEvent &event, T object)
 
- Protected Member Functions inherited from ctkPluginTrackerCustomizer< QSharedPointer< ctkPlugin > >
virtual void modifiedPlugin (QSharedPointer< ctkPlugin > plugin, const ctkPluginEvent &event, QSharedPointer< ctkPlugin > object)=0
 
virtual void removedPlugin (QSharedPointer< ctkPlugin > plugin, const ctkPluginEvent &event, QSharedPointer< ctkPlugin > object)=0
 
virtual ~ctkPluginTrackerCustomizer ()
 

Friends

class ctkPluginTrackerPrivate< T >
 
class ctkTrackedPlugin< T >
 

Detailed Description

template<class T = QSharedPointer<ctkPlugin>>
class ctkPluginTracker< T >

The ctkPluginTracker class simplifies tracking plugins much like the ctkServiceTracker simplifies tracking services.

A ctkPluginTracker is constructed with state criteria and a ctkPluginTrackerCustomizer object. A ctkPluginTracker can use the ctkPluginTrackerCustomizer to select which plugins are tracked and to create a customized object to be tracked with the plugin. The ctkPluginTracker can then be opened to begin tracking all plugins whose state matches the specified state criteria.

The getPlugins method can be called to get the ctkPlugin objects of the plugins being tracked. The getObject method can be called to get the customized object for a tracked plugin.

The ctkPluginTracker class is thread-safe. It does not call a ctkPluginTrackerCustomizer while holding any locks. ctkPluginTrackerCustomizer implementations must also be thread-safe.

Template Parameters
TThe type of the tracked object. The type must be an assignable datatype, provide a boolean conversion function, and provide a constructor and an assignment operator which can handle 0 as an argument.
Remarks
This class is thread safe.

Definition at line 65 of file ctkPluginTracker.h.

Constructor & Destructor Documentation

◆ ~ctkPluginTracker()

template<class T = QSharedPointer<ctkPlugin>>
ctkPluginTracker< T >::~ctkPluginTracker ( )

◆ ctkPluginTracker()

template<class T = QSharedPointer<ctkPlugin>>
ctkPluginTracker< T >::ctkPluginTracker ( ctkPluginContext context,
ctkPlugin::States  stateMask,
ctkPluginTrackerCustomizer< T > *  customizer = 0 
)

Create a ctkPluginTracker for plugins whose state is present in the specified state mask.

Plugins whose state is present on the specified state mask will be tracked by this ctkPluginTracker.

Parameters
contextThe ctkPluginContext against which the tracking is done.
stateMaskThe bit mask of the ORing of the plugin states to be tracked.
customizerThe customizer object to call when plugins are added, modified, or removed in this ctkPluginTracker. If customizer is null, then this ctkPluginTracker will be used as the ctkPluginTrackerCustomizer and this ctkPluginTracker will call the ctkPluginTrackerCustomizer methods on itself. If the customizer is not null, this ctkPluginTracker takes ownership of the customizer.
See also
ctkPlugin::getState()

Member Function Documentation

◆ addingPlugin()

template<class T = QSharedPointer<ctkPlugin>>
T ctkPluginTracker< T >::addingPlugin ( QSharedPointer< ctkPlugin plugin,
const ctkPluginEvent event 
)
protectedvirtual

Default implementation of the ctkPluginTrackerCustomizer::addingPlugin method.

This method is only called when this ctkPluginTracker has been constructed with a null ctkPluginTrackerCustomizer argument.

This implementation simply returns the specified ctkPlugin* in a QVariant.

This method can be overridden in a subclass to customize the object to be tracked for the plugin being added.

Parameters
pluginThe ctkPlugin being added to this ctkPluginTracker object.
eventThe plugin event which caused this customizer method to be called or an invalid event if there is no plugin event associated with the call to this method.
Returns
The specified plugin.
See also
ctkPluginTrackerCustomizer::addingPlugin(ctkPlugin*, const ctkPluginEvent&)

Implements ctkPluginTrackerCustomizer< QSharedPointer< ctkPlugin > >.

◆ close()

template<class T = QSharedPointer<ctkPlugin>>
virtual void ctkPluginTracker< T >::close ( )
virtual

Close this ctkPluginTracker.

This method should be called when this ctkPluginTracker should end the tracking of plugins.

This implementation calls getPlugins() to get the list of tracked plugins to remove.

◆ getObject()

template<class T = QSharedPointer<ctkPlugin>>
virtual T ctkPluginTracker< T >::getObject ( QSharedPointer< ctkPlugin plugin) const
virtual

Returns the customized object for the specified ctkPlugin if the specified plugin is being tracked by this ctkPluginTracker.

Parameters
pluginThe ctkPlugin being tracked.
Returns
The customized object for the specified ctkPlugin or null if the specified ctkPlugin is not being tracked.

◆ getPlugins()

template<class T = QSharedPointer<ctkPlugin>>
virtual QList<QSharedPointer<ctkPlugin> > ctkPluginTracker< T >::getPlugins ( ) const
virtual

Return a list of ctkPlugins for all plugins being tracked by this ctkPluginTracker.

Returns
A list of ctkPlugins.

◆ getTracked()

template<class T = QSharedPointer<ctkPlugin>>
virtual QMap<QSharedPointer<ctkPlugin>, T> ctkPluginTracker< T >::getTracked ( ) const
virtual

Return a QMap with the ctkPlugins and customized objects for all plugins being tracked by this ctkPluginTracker.

Returns
A QMap with the ctkPlugins and customized objects for all services being tracked by this ctkPluginTracker. If no plugins are being tracked, then the returned map is empty.

◆ getTrackingCount()

template<class T = QSharedPointer<ctkPlugin>>
virtual int ctkPluginTracker< T >::getTrackingCount ( ) const
virtual

Returns the tracking count for this ctkPluginTracker.

The tracking count is initialized to 0 when this ctkPluginTracker is opened. Every time a plugin is added, modified or removed from this ctkPluginTracker the tracking count is incremented.

The tracking count can be used to determine if this ctkPluginTracker has added, modified or removed a plugin by comparing a tracking count value previously collected with the current tracking count value. If the value has not changed, then no plugin has been added, modified or removed from this ctkPluginTracker since the previous tracking count was collected.

Returns
The tracking count for this ctkPluginTracker or -1 if this ctkPluginTracker is not open.

◆ isEmpty()

template<class T = QSharedPointer<ctkPlugin>>
virtual bool ctkPluginTracker< T >::isEmpty ( ) const
virtual

Return if this ctkPluginTracker is empty.

Returns
true if this ctkPluginTracker is not tracking any plugins.

◆ modifiedPlugin()

template<class T = QSharedPointer<ctkPlugin>>
void ctkPluginTracker< T >::modifiedPlugin ( QSharedPointer< ctkPlugin plugin,
const ctkPluginEvent event,
object 
)
protected

Default implementation of the ctkPluginTrackerCustomizer::modifiedPlugin method.

This method is only called when this ctkPluginTracker has been constructed with a null ctkPluginTrackerCustomizer argument.

This implementation does nothing.

Parameters
pluginThe ctkPlugin whose state has been modified.
eventThe plugin event which caused this customizer method to be called or an invalid event if there is no plugin event associated with the call to this method.
objectThe customized object for the specified ctkPlugin.
See also
ctkPluginTrackerCustomizer::modifiedPlugin(ctkPlugin*, const ctkPluginEvent&, QVariant)

◆ open()

template<class T = QSharedPointer<ctkPlugin>>
virtual void ctkPluginTracker< T >::open ( )
virtual

Open this ctkPluginTracker and begin tracking plugins.

ctkPlugin's which match the state criteria specified when this ctkPluginTracker was created are now tracked by this ctkPluginTracker.

Exceptions
ctkIllegalStateExceptionIf the ctkPluginContext with which this ctkPluginTracker was created is no longer valid.

◆ remove()

template<class T = QSharedPointer<ctkPlugin>>
virtual void ctkPluginTracker< T >::remove ( QSharedPointer< ctkPlugin plugin)
virtual

Remove a plugin from this ctkPluginTracker.

The specified plugin will be removed from this ctkPluginTracker. If the specified plugin was being tracked then the ctkPluginTrackerCustomizer::removedPlugin method will be called for that plugin.

Parameters
pluginThe ctkPlugin to be removed.

◆ removedPlugin()

template<class T = QSharedPointer<ctkPlugin>>
void ctkPluginTracker< T >::removedPlugin ( QSharedPointer< ctkPlugin plugin,
const ctkPluginEvent event,
object 
)
protected

Default implementation of the ctkPluginTrackerCustomizer::removedPlugin method.

This method is only called when this ctkPluginTracker has been constructed with a null ctkPluginTrackerCustomizer argument.

This implementation does nothing.

Parameters
pluginThe ctkPlugin being removed.
eventThe plugin event which caused this customizer method to be called or an invalid event if there is no plugin event associated with the call to this method.
objectThe customized object for the specified plugin.
See also
ctkPluginTrackerCustomizer::removedPlugin(ctkPlugin*, const ctkPluginEvent&, QVariant)

◆ size()

template<class T = QSharedPointer<ctkPlugin>>
virtual int ctkPluginTracker< T >::size ( ) const
virtual

Return the number of plugins being tracked by this ctkPluginTracker.

Returns
The number of plugins being tracked.

Friends And Related Function Documentation

◆ ctkPluginTrackerPrivate< T >

template<class T = QSharedPointer<ctkPlugin>>
friend class ctkPluginTrackerPrivate< T >
friend

Definition at line 276 of file ctkPluginTracker.h.

◆ ctkTrackedPlugin< T >

template<class T = QSharedPointer<ctkPlugin>>
friend class ctkTrackedPlugin< T >
friend

Definition at line 276 of file ctkPluginTracker.h.


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