Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QServiceManager Class Reference

The QServiceManager class enables the loading of service plugins and the (de)registration of services. More...

    #include <QServiceManager>

Inherits QObject.


Public Types

enum Error { NoError, StorageAccessError, InvalidServiceLocation, InvalidServiceXml, ..., UnknownError }
enum Scope { UserScope, SystemScope }

Public Functions

QServiceManager ( QObject * parent = 0 )
QServiceManager ( Scope scope, QObject * parent = 0 )
~QServiceManager ()
bool addService ( const QString & xmlFilePath )
bool addService ( QIODevice * device )
Error error () const
QList<QServiceInterfaceDescriptor> findInterfaces ( const QServiceFilter & filter = QServiceFilter() ) const
QList<QServiceInterfaceDescriptor> findInterfaces ( const QString & serviceName ) const
QStringList findServices ( const QString & interfaceName = QString() ) const
T * getInterface ( const QString & interfaceName, QServiceContext * context = 0, QAbstractSecuritySession * session = 0 )
T * getInterface ( const QServiceInterfaceDescriptor & serviceDescriptor, QServiceContext * context, QAbstractSecuritySession * session )
QServiceInterfaceDescriptor interfaceDefault ( const QString & interfaceName ) const
QObject * loadInterface ( const QString & interfaceName, QServiceContext * context = 0, QAbstractSecuritySession * session = 0 )
QObject * loadInterface ( const QServiceInterfaceDescriptor & descriptor, QServiceContext * context = 0, QAbstractSecuritySession * session = 0 )
bool removeService ( const QString & serviceName )
Scope scope () const
bool setInterfaceDefault ( const QString & service, const QString & interfaceName )
bool setInterfaceDefault ( const QServiceInterfaceDescriptor & descriptor )
  • 29 public functions inherited from QObject

Signals

void serviceAdded ( const QString & serviceName, QServiceManager::Scope scope )
void serviceRemoved ( const QString & serviceName, QServiceManager::Scope scope )

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 public type inherited from QObject
  • 4 static public members inherited from QObject
  • 7 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

The QServiceManager class enables the loading of service plugins and the (de)registration of services.

A service is a stand-alone component that can be used by multiple clients. Each service implementation must derive from QObject. Clients request a reference to a service via loadInterface() or getInterface().

Services are separate deliveries in the form of plug-ins. New services can be (de)registered at any time via addService() and removeService() respectively. Such an event is published via the serviceAdded() and serviceRemoved() signal. Each service plug-in must implement QServicePluginInterface.

Each plug-in may support multiple interfaces and may even provide multiple implementations for the same interface. Individual implementations are identified via QServiceInterfaceDescriptor. For a more detailed explanation of services and how they relate to interface and their implementations please see QServiceInterfaceDescriptor.

See also QServicePluginInterface, QServiceContext, and QAbstractSecuritySession.


Member Type Documentation

enum QServiceManager::Error

Defines the possible errors for the service manager.

ConstantValueDescription
QServiceManager::NoError0No error occurred.
QServiceManager::StorageAccessError1The service data storage is not accessible. This could be because the caller does not have the required permissions.
QServiceManager::InvalidServiceLocation2The service was not found at its specified location.
QServiceManager::InvalidServiceXml3The XML defining the service metadata is invalid.
QServiceManager::InvalidServiceInterfaceDescriptor4The service interface descriptor is invalid, or refers to an interface implementation that cannot be accessed in the current scope.
QServiceManager::ServiceAlreadyExists5Another service has previously been registered with the same location.
QServiceManager::ImplementationAlreadyExists6Another service that implements the same interface version has previously been registered.
QServiceManager::PluginLoadingFailed7The service plugin cannot be loaded.
QServiceManager::ComponentNotFound8The service or interface implementation has not been registered.
QServiceManager::ServiceCapabilityDenied9The security session does not allow the service based on its capabilities.
QServiceManager::UnknownError100An unknown error occurred.

enum QServiceManager::Scope

ConstantValueDescription
QServiceManager::UserScope0When adding and removing services, uses a storage location specific to the current user. When searching for services and interface implementations, first searches in the user-specific location; if the service or interface implementation is not found, searches in the system-wide storage location (if the user has sufficient permissions to do so).
QServiceManager::SystemScope1When adding and removing services, use a system-wide storage location accessible to all users. When searching for services and interface implementations, search only in the system-wide storage location.


Member Function Documentation

QServiceManager::QServiceManager ( QObject * parent = 0 )

Creates a service manager with the given parent.

The scope will default to QServiceManager::UserScope.

QServiceManager::QServiceManager ( Scope scope, QObject * parent = 0 )

Creates a service manager with the given scope and parent.

QServiceManager::~QServiceManager ()

Destroys the service manager.

bool QServiceManager::addService ( const QString & xmlFilePath )

Registers the service defined by the XML file at xmlFilePath. Returns true if the registration succeeded, and false otherwise.

If a previously unkown interface is added the newly registered service automatically becomes the new default service provider for the new interface.

A service plugin cannot be added if another service is already registered with the same plugin file path. A service plugin also cannot be added if the service is already registered and implements any of the same interface versions that the new plugin implements.

See also removeService() and setInterfaceDefault().

bool QServiceManager::addService ( QIODevice * device )

Registers the service defined by the XML data from the given device. Returns true if the registration succeeded, and false otherwise. If a previously unkown interface is added the newly registered service automatically becomes the new default service provider for the new interface.

Registering a service also causes QServicePluginInterface::installService() to be called on the service. If the service plugin is not accessible (e.g. if the plugin file is not found) and installService() cannot be invoked on the service, the registration fails and this method returns false.

A service plugin cannot be added if another service is already registered with the same plugin file path. A service plugin also cannot be added if the service is already registered and implements any of the same interface versions that the new plugin implements.

Services are always added based on the scope() of the current service manager instance.

See also removeService() and setInterfaceDefault().

Error QServiceManager::error () const

Returns the type of error that last occurred.

QList<QServiceInterfaceDescriptor> QServiceManager::findInterfaces ( const QServiceFilter & filter = QServiceFilter() ) const

Returns a list of the interfaces that match the specified filter.

QList<QServiceInterfaceDescriptor> QServiceManager::findInterfaces ( const QString & serviceName ) const

Returns a list of the interfaces provided by the service named serviceName. If serviceName is empty, this function returns a list of all available interfaces in this manager's scope.

QStringList QServiceManager::findServices ( const QString & interfaceName = QString() ) const

Returns a list of the services that provide the interface specified by interfaceName. If interfaceName is empty, this function returns a list of all available services in this manager's scope.

T * QServiceManager::getInterface ( const QString & interfaceName, QServiceContext * context = 0, QAbstractSecuritySession * session = 0 )

Loads the service object implementing interfaceName, as provided by the default service for this interface, using the given context and session. context and session object are owned by the caller of this function. The template class must be derived from QObject.

If interfaceName is not a known interface the returned pointer will be null.

The caller takes ownership of the returned pointer.

The security session object is not mandatory. If the session pointer is null, the service manager will not perform any checks. Therefore it is assumed that the service manager client is trusted as it controls whether service capabilities are enforced during service loading.

See also setInterfaceDefault() and interfaceDefault().

T * QServiceManager::getInterface ( const QServiceInterfaceDescriptor & serviceDescriptor, QServiceContext * context, QAbstractSecuritySession * session )

Loads the service object identified by serviceDescriptor using the given context and session. context and session object are owned by the caller of this function. The template class must be derived from QObject.

If the serviceDescriptor is not valid the returned pointer will be null.

The caller takes ownership of the returned pointer.

The security session object is not mandatory. If the session pointer is null, the service manager will not perform any checks. Therefore it is assumed that the service manager client is trusted as it controls whether service capabilities are enforced during service loading.

QServiceInterfaceDescriptor QServiceManager::interfaceDefault ( const QString & interfaceName ) const

Returns the default interface implementation for the given interfaceName.

See also setInterfaceDefault().

QObject * QServiceManager::loadInterface ( const QString & interfaceName, QServiceContext * context = 0, QAbstractSecuritySession * session = 0 )

Loads and returns the interface specified by interfaceName, as provided by the default service for this interface, using the given context and session. context and session object are owned by the caller of this function.

The caller takes ownership of the returned pointer.

This function returns a null pointer if the requested service cannot be found.

The security session object is not mandatory. If the session pointer is null, the service manager will not perform any checks. Therefore it is assumed that the service manager client is trusted as it controls whether service capabilities are enforced during service loading.

See also setInterfaceDefault() and interfaceDefault().

QObject * QServiceManager::loadInterface ( const QServiceInterfaceDescriptor & descriptor, QServiceContext * context = 0, QAbstractSecuritySession * session = 0 )

Loads and returns the interface specified by descriptor using the given context and session. context and session object are owned by the caller of this function.

The caller takes ownership of the returned pointer.

This function returns a null pointer if the requested service cannot be found.

The security session object is not mandatory. If the session pointer is null, the service manager will not perform any checks. Therefore it is assumed that the service manager client is trusted as it controls whether service capabilities are enforced during service loading.

bool QServiceManager::removeService ( const QString & serviceName )

Unregisters the service specified by serviceName.

Returns true if the unregistration succeeded, and false otherwise.

If a default service implementation is removed and there are other implementations for the same interface, the service manager chooses the implementation with the highest version number as the new default. If there is more than one serivce with the same version number, the service manager makes a random choice with regards to the new default implementation. If this is not the desired behaviour the default selection should be updated via setInterfaceDefault().

Services are always removed based on the scope() of the current service manager instance.

See also addService().

Scope QServiceManager::scope () const

Returns the scope used for registering and searching of services.

void QServiceManager::serviceAdded ( const QString & serviceName, QServiceManager::Scope scope )   [signal]

This signal is emited whenever a new service with the given serviceName has been registered with the service manager. scope indicates where the service was added.

If the manager scope is QServiceManager::SystemScope, it will not receive notifications about services added in the user scope.

See also addService().

void QServiceManager::serviceRemoved ( const QString & serviceName, QServiceManager::Scope scope )   [signal]

This signal is emited whenever a service with the given serviceName has been deregistered with the service manager. scope indicates where the service was added.

If the manager scope is QServiceManager::SystemScope, it will not receive notifications about services removed in the user scope.

See also removeService().

bool QServiceManager::setInterfaceDefault ( const QString & service, const QString & interfaceName )

Sets the default interface implementation for interfaceName to the matching interface implementation provided by service.

If service provides more than one interface implementation for interfaceName, the newest version of the interface is set as the default.

Returns true if the operation succeeded, and false otherwise.

Note: When in system scope, the service must be a system-wide service rather than a user-specific service; otherwise, this will fail.

See also interfaceDefault().

bool QServiceManager::setInterfaceDefault ( const QServiceInterfaceDescriptor & descriptor )

This is an overloaded function.

Sets the interface implementation specified by descriptor to be the default implementation for the particular interface specified in the descriptor.

Returns true if the operation succeeded, and false otherwise.

Note: When in system scope, the descriptor must refer to a system-wide service rather than a user-specific service; otherwise, this will fail.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 94
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 43
  4. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 9
Page suivante

Le Qt Quarterly au hasard

Logo

Des apparences personnalisées utilisant les feuilles de style

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtmobility-1.0-tp
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web