/*============================================================================= Library: CTK Copyright (c) 2010 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 CTKSERVICEREGISTRATION_H #define CTKSERVICEREGISTRATION_H #include "ctkPluginContext.h" #include "ctkServiceReference.h" namespace ctk { class ServiceRegistrationPrivate; /** * A registered service. * *
* The Framework returns a ServiceRegistration object when a
* PluginContext#registerService() method invocation is successful.
* The ServiceRegistration object is for the private use of the
* registering plugin and should not be shared with other plugins.
*
* The ServiceRegistration object may be used to update the
* properties of the service or to unregister the service.
*
* @see PluginContext#registerService()
* @threadsafe
*/
class ServiceRegistration {
Q_DECLARE_PRIVATE(ServiceRegistration)
public:
/**
* Returns a ServiceReference object for a service being
* registered.
*
* The ServiceReference object may be shared with other
* plugins.
*
* @throws std::logic_error If this
* ServiceRegistration object has already been
* unregistered.
* @return ServiceReference object.
*/
ServiceReference getReference() const;
/**
* Updates the properties associated with a service.
*
*
* The {@link PluginConstants#OBJECTCLASS} and {@link PluginConstants#SERVICE_ID} keys * cannot be modified by this method. These values are set by the Framework * when the service is registered in the environment. * *
* The following steps are required to modify service properties: *
ServiceRegistration
* object has already been unregistered.
* @throws std::invalid_argument If properties contains
* case variants of the same key name.
*/
void setProperties(const PluginContext::ServiceProperties& properties);
/**
* Unregisters a service. Remove a ServiceRegistration object
* from the Framework service registry. All ServiceReference
* objects associated with this ServiceRegistration object
* can no longer be used to interact with the service once unregistration is
* complete.
*
* * The following steps are required to unregister a service: *
ServiceReference objects for the service may no longer be
* used to get a service object for the service.
* ServiceFactory#ungetService method is called to release
* the service object for the plugin.
* ServiceRegistration object has already been
* unregistered.
* @see BundleContext#ungetService
* @see ServiceFactory#ungetService
*/
void unregister() const;
private:
ServiceRegistration(Plugin* plugin, QObject* service,
const PluginContext::ServiceProperties& props);
ServiceRegistrationPrivate * const d_ptr;
};
}
#endif // CTKSERVICEREGISTRATION_H