File indexing completed on 2024-04-28 04:40:42

0001 /* SPDX-FileCopyrightText: 2020 Casper Meijn <casper@meijn.net>
0002  * SPDX-License-Identifier: GPL-3.0-or-later
0003  *
0004  */
0005 
0006 #ifndef WSDISCOVERYSERVICEAGGREGATOR_H
0007 #define WSDISCOVERYSERVICEAGGREGATOR_H
0008 
0009 #include "wsdiscoveryclient_export.h"
0010 #include <QObject>
0011 
0012 class WSDiscoveryTargetService;
0013 class WSDiscoveryServiceAggregatorPrivate;
0014 
0015 /*!
0016  * \brief Aggregates multiple updates from the same WSDiscoveryTargetService
0017  *
0018  * When receiving multiple probe and resolve matches of the same service, this
0019  * class will aggregate those into a single shared instance. This eases the
0020  * administration needed by the application.
0021  */
0022 class WSDISCOVERYCLIENT_EXPORT WSDiscoveryServiceAggregator : public QObject
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     /*!
0028      * Create a WSDiscoveryClient
0029      * \param parent The QObject parent
0030      */
0031     WSDiscoveryServiceAggregator(QObject *parent = nullptr);
0032 
0033     /*!
0034      * Destructor
0035      */
0036     ~WSDiscoveryServiceAggregator();
0037 
0038 Q_SIGNALS:
0039     /*!
0040      * Emitted when a service has new information. The service instance is
0041      * reused, when a new update is received. Therefore you can compare the
0042      * pointers when looking for updates of a previous received service.
0043      * \param updatedService A pointer to the updated service
0044      */
0045     void serviceUpdated(const QSharedPointer<WSDiscoveryTargetService> &updatedService);
0046 
0047 public Q_SLOTS:
0048     /*!
0049      * Provides a new service update.
0050      * \param receivedService The service with updated information
0051      */
0052     void updateService(const WSDiscoveryTargetService &receivedService);
0053 
0054 private:
0055     WSDiscoveryServiceAggregatorPrivate *const d_ptr;
0056     Q_DECLARE_PRIVATE(WSDiscoveryServiceAggregator)
0057 };
0058 
0059 #endif // WSDISCOVERYSERVICEAGGREGATOR_H