/*============================================================================= 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 CTKSERVICETRACKERCUSTOMIZER_H #define CTKSERVICETRACKERCUSTOMIZER_H #include /** * \ingroup PluginFramework * * The ctkServiceTrackerCustomizer interface allows a * ctkServiceTracker to customize the service objects that are * tracked. A ctkServiceTrackerCustomizer is called when a service is * being added to a ctkServiceTracker. The * ctkServiceTrackerCustomizer can then return an object for the * tracked service. A ctkServiceTrackerCustomizer is also called when * a tracked service is modified or has been removed from a * ctkServiceTracker. * *

* The methods in this interface may be called as the result of a * ctkServiceEvent being received by a ctkServiceTracker. * Since ctkServiceEvents are synchronously delivered by the * Framework, it is highly recommended that implementations of these methods do * not register (ctkPluginContext::registerService), modify ( * ctkServiceRegistration::setProperties) or unregister ( * ctkServiceRegistration::unregister) a service while being * synchronized on any object. * *

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

* This method is called before a service which matched the search * parameters of the ctkServiceTracker is added to the * ctkServiceTracker. This method should return the service object * to be tracked for the specified ctkServiceReference. The * returned service object is stored in the ctkServiceTracker and * is available from the getService and * getServices methods. * * @param reference The reference to the service being added to the * ctkServiceTracker. * @return The service object to be tracked for the specified referenced * service or 0 if the specified referenced service * should not be tracked. */ virtual T addingService(const ctkServiceReference& reference) = 0; /** * A service tracked by the ctkServiceTracker has been modified. * *

* This method is called when a service being tracked by the * ctkServiceTracker has had it properties modified. * * @param reference The reference to the service that has been modified. * @param service The service object for the specified referenced service. */ virtual void modifiedService(const ctkServiceReference& reference, T service) = 0; /** * A service tracked by the ctkServiceTracker has been removed. * *

* This method is called after a service is no longer being tracked by the * ctkServiceTracker. * * @param reference The reference to the service that has been removed. * @param service The service object for the specified referenced service. */ virtual void removedService(const ctkServiceReference& reference, T service) = 0; }; #endif // CTKSERVICETRACKERCUSTOMIZER_H