/*============================================================================= Library: CTK Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =============================================================================*/ #ifndef CTKPLUGINTRACKERCUSTOMIZER_H #define CTKPLUGINTRACKERCUSTOMIZER_H #include #include "ctkPluginEvent.h" class QObject; class ctkPlugin; /** * \ingroup PluginFramework * * The ctkPluginTrackerCustomizer interface allows a * ctkPluginTracker to customize the ctkPlugins that are * tracked. A ctkPluginTrackerCustomizer is called when a plugin is * being added to a ctkPluginTracker. The * ctkPluginTrackerCustomizer can then return an object for the * tracked plugin. A ctkPluginTrackerCustomizer is also called when a * tracked plugin is modified or has been removed from a * ctkPluginTracker. * *

* The methods in this interface may be called as the result of a * ctkPluginEvent being received by a ctkPluginTracker. * Since ctkPluginEvents are received synchronously by the * ctkPluginTracker, it is highly recommended that implementations of * these methods do not alter plugin states while being synchronized on any * object. * *

* The ctkPluginTracker class is thread-safe. It does not call a * ctkPluginTrackerCustomizer while holding any locks. * ctkPluginTrackerCustomizer implementations must also be * thread-safe. * * \tparam T The type of the tracked object. * \remarks This class is thread safe. */ template struct ctkPluginTrackerCustomizer { virtual ~ctkPluginTrackerCustomizer() {} /** * A plugin is being added to the ctkPluginTracker. * *

* This method is called before a plugin which matched the search parameters * of the ctkPluginTracker is added to the * ctkPluginTracker. This method should return the object to be * tracked for the specified ctkPlugin. The returned object is * stored in the ctkPluginTracker and is available from the * ctkPluginTracker::getObject(ctkPlugin*) method. * * @param plugin The ctkPlugin being added to the * ctkPluginTracker. * @param event The plugin event which caused this customizer method to be * called or an invalid event (ctkPluginEvent::isNull() returns true) * if there is no plugin event associated * with the call to this method. * @return The object to be tracked for the specified ctkPlugin * object or null if the specified ctkPlugin * object should not be tracked. */ virtual T addingPlugin(QSharedPointer plugin, const ctkPluginEvent& event) = 0; /** * A plugin tracked by the ctkPluginTracker has been modified. * *

* This method is called when a plugin being tracked by the * ctkPluginTracker has had its state modified. * * @param plugin The ctkPlugin whose state has been modified. * @param event The plugin event which caused this customizer method to be * called or an invalid event (ctkPluginEvent::isNull() returns true) * if there is no plugin event associated * with the call to this method. * @param object The tracked object for the specified plugin. */ virtual void modifiedPlugin(QSharedPointer plugin, const ctkPluginEvent& event, T object) = 0; /** * A plugin tracked by the ctkPluginTracker has been removed. * *

* This method is called after a plugin is no longer being tracked by the * ctkPluginTracker. * * @param plugin The ctkPlugin that has been removed. * @param event The plugin event which caused this customizer method to be * called or an invalid event (ctkPluginEvent::isNull() returns true) * if there is no plugin event associated * with the call to this method. * @param object The tracked object for the specified plugin. */ virtual void removedPlugin(QSharedPointer plugin, const ctkPluginEvent& event, T object) = 0; }; #endif // CTKPLUGINTRACKERCUSTOMIZER_H