2024-02-16 11:31:12 -05:00
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2024 Jon Beniston <jon@beniston.com> //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
# ifndef SDRBASE_AVAILABLECHANNELORFEATUREHANDLER_H_
# define SDRBASE_AVAILABLECHANNELORFEATUREHANDLER_H_
# include "availablechannelorfeature.h"
# include "export.h"
2024-04-20 05:51:29 -04:00
# include "util/messagequeue.h"
2024-02-16 11:31:12 -05:00
class ChannelAPI ;
class Feature ;
// Utility class to help keeping track of list of available channels or features and optionally register pipes to them
class SDRBASE_API AvailableChannelOrFeatureHandler : public QObject
{
Q_OBJECT
public :
// Use this constructor to just keep track of available channels and features with specified URIs and kinds
AvailableChannelOrFeatureHandler ( QStringList uris , const QString & kinds = " RTMF " ) :
m_uris ( uris ) ,
m_kinds ( kinds )
{
init ( ) ;
}
// Use this constructor to keep track of available channels and features with specified URIs and kinds and register pipes with the given names to them
AvailableChannelOrFeatureHandler ( QStringList uris , QStringList pipeNames , const QString & kinds = " RTMF " ) :
m_uris ( uris ) ,
m_pipeNames ( pipeNames ) ,
m_kinds ( kinds )
{
init ( ) ;
}
void scanAvailableChannelsAndFeatures ( ) ;
const AvailableChannelOrFeatureList & getAvailableChannelOrFeatureList ( ) const {
return m_availableChannelOrFeatureList ;
}
2024-02-16 13:08:31 -05:00
QObject * registerPipes ( const QString & longIdFrom , const QStringList & pipeNames ) ;
void deregisterPipes ( QObject * from , const QStringList & pipeNames ) ;
2024-02-16 11:31:12 -05:00
private :
AvailableChannelOrFeatureList m_availableChannelOrFeatureList ;
QStringList m_uris ; //!< URIs of channels/features we want to create a list for
QStringList m_pipeNames ; //!< List of pipe names to register
QString m_kinds ;
void init ( ) ;
void registerPipe ( const QString & pipeName , QObject * channelOrFeature ) ;
private slots :
void handleChannelAdded ( int deviceSetIndex , ChannelAPI * channel ) ;
void handleChannelRemoved ( int deviceSetIndex , ChannelAPI * channel ) ;
void handleStreamIndexChanged ( int streamIndex ) ;
void handleFeatureAdded ( int featureSetIndex , Feature * feature ) ;
void handleFeatureRemoved ( int featureSetIndex , Feature * feature ) ;
signals :
2024-04-04 10:21:09 -04:00
void channelsOrFeaturesChanged ( const QStringList & renameFrom , const QStringList & renameTo , const QStringList & removed , const QStringList & added ) ; //!< Emitted when list of channels or features has changed
2024-02-16 11:31:12 -05:00
void messageEnqueued ( MessageQueue * messageQueue ) ; //!< Emitted when message enqueued to a pipe
} ;
# endif // SDRBASE_AVAILABLECHANNELORFEATUREHANDLER_H_