![]() |
CTK
0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
|
#include <Libs/PluginFramework/ctkPluginTracker.h>
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 | |
T | 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) |
![]() | |
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 > |
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.
T | The 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. |
Definition at line 65 of file ctkPluginTracker.h.
ctkPluginTracker< T >::~ctkPluginTracker | ( | ) |
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
.
context | The ctkPluginContext against which the tracking is done. |
stateMask | The bit mask of the OR ing of the plugin states to be tracked. |
customizer | The 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. |
|
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.
plugin | The ctkPlugin being added to this ctkPluginTracker object. |
event | The 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. |
Implements ctkPluginTrackerCustomizer< QSharedPointer< ctkPlugin > >.
|
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.
|
virtual |
Returns the customized object for the specified ctkPlugin
if the specified plugin is being tracked by this ctkPluginTracker
.
plugin | The ctkPlugin being tracked. |
|
virtual |
Return a list of ctkPlugin
s for all plugins being tracked by this ctkPluginTracker
.
ctkPlugin
s.
|
virtual |
Return a QMap
with the ctkPlugin
s and customized objects for all plugins being tracked by this ctkPluginTracker
.
QMap
with the ctkPlugin
s and customized objects for all services being tracked by this ctkPluginTracker
. If no plugins are being tracked, then the returned map is empty.
|
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.
ctkPluginTracker
or -1 if this ctkPluginTracker
is not open.
|
virtual |
Return if this ctkPluginTracker
is empty.
true
if this ctkPluginTracker
is not tracking any plugins.
|
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.
plugin | The ctkPlugin whose state has been modified. |
event | The 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. |
object | The customized object for the specified ctkPlugin. |
|
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
.
ctkIllegalStateException | If the ctkPluginContext with which this ctkPluginTracker was created is no longer valid. |
|
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.
plugin | The ctkPlugin to be removed. |
|
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.
plugin | The ctkPlugin being removed. |
event | The 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. |
object | The customized object for the specified plugin. |
|
virtual |
Return the number of plugins being tracked by this ctkPluginTracker
.
|
friend |
Definition at line 276 of file ctkPluginTracker.h.
|
friend |
Definition at line 276 of file ctkPluginTracker.h.