QServiceLocator Class

(Qt3D::QServiceLocator)

Service locator used by aspects to retrieve pointers to concrete service objects More...

Header: #include <QServiceLocator>
qmake: QT += 3dcore

Public Types

enum ServiceType { SystemInformation, OpenGLInformation, CollisionService, FrameAdvanceService, UserService }

Public Functions

QServiceLocator()
~QServiceLocator()
QAbstractFrameAdvanceService * frameAdvanceService()
QOpenGLInformationService * openGLInformation()
void registerServiceProvider(int serviceType, QAbstractServiceProvider * provider)
T * service(int serviceType)
int serviceCount() const
QSystemInformationService * systemInformation()
void unregisterServiceProvider(int serviceType)

Detailed Description

Service locator used by aspects to retrieve pointers to concrete service objects

The Qt3D::QServiceLocator class can be used by aspects to obtain pointers to concrete providers of abstract service interfaces. A subclass of Qt3D::QAbstractServiceProvider encapsulates a service that can be provided by an aspect for other parts of the system. For example, an aspect may wish to know the current frame number, or how many CPU cores are available in the Qt3D tasking threadpool.

Aspects or the Qt3D::QAspectEngine are able to register objects as providers of services. The service locator itself can be accessed via the Qt3D::QAbstractAspect::services() function.

As a convenience, the service locator provides methods to access services provided by built in Qt3D aspects. Currently these are Qt3D::QSystemInformationService and Qt3D::QOpenGLInformationService. For such services, the service provider will never return a null pointer. The default implementations of these services are simple null or do nothing implementations.

Member Type Documentation

enum QServiceLocator::ServiceType

Member Function Documentation

QServiceLocator::QServiceLocator()

Creates an instance of QServiceLocator.

QServiceLocator::~QServiceLocator()

Destroys a QServiceLocator object

QAbstractFrameAdvanceService * QServiceLocator::frameAdvanceService()

Returns a pointer to a provider for the frame advance service. If no provider has been explicitly registered for this service type, then a pointer to a simple timer-based service is returned.

QOpenGLInformationService * QServiceLocator::openGLInformation()

Returns a pointer to a provider for the OpenGL information service. If no provider has been explicitly registered for this service type, then a pointer to a null, do- nothing service is returned.

void QServiceLocator::registerServiceProvider(int serviceType, QAbstractServiceProvider * provider)

Registers provider service provider for the service serviceType. This replaces any existing provider for this service. The service provider does not take ownership of the provider.

See also unregisterServiceProvider(), serviceCount(), and service().

T * QServiceLocator::service(int serviceType)

Returns a pointer to the service provider for serviceType. If no provider has been explicitly registered, this returns a null pointer for non-Qt3D provided default services and a null pointer for non-default services.

See also registerService().

int QServiceLocator::serviceCount() const

Returns the number of registered services.

QSystemInformationService * QServiceLocator::systemInformation()

Returns a pointer to a provider for the system information service. If no provider has been explicitly registered for this service type, then a pointer to a null, do- nothing service is returned.

void QServiceLocator::unregisterServiceProvider(int serviceType)

Unregisters any existing provider for the serviceType.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.