mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-18 06:11:46 -05:00
78 lines
3.7 KiB
C++
78 lines
3.7 KiB
C++
///////////////////////////////////////////////////////////////////////////////////
|
|
// 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_AVAILABLECHANNELORFEATURE_H_
|
|
#define SDRBASE_AVAILABLECHANNELORFEATURE_H_
|
|
|
|
#include "pipes/messagepipes.h"
|
|
#include "export.h"
|
|
|
|
struct AvailableChannelOrFeature
|
|
{
|
|
QChar m_kind; //!< 'R' or 'T' for channel, 'M' for MIMO channel, 'F' for feature as from MainCore::getDeviceSetTypeId
|
|
int m_superIndex; //!< Device Set index or Feature Set index
|
|
int m_index; //!< Channel or Feature index
|
|
int m_streamIndex; //!< For MIMO channels only
|
|
QString m_type; //!< Plugin type (E.g. NFMDemod)
|
|
QObject *m_object; //!< Pointer to the object (ChannelAPI or Feature object)
|
|
|
|
AvailableChannelOrFeature() = default;
|
|
AvailableChannelOrFeature(const AvailableChannelOrFeature&) = default;
|
|
AvailableChannelOrFeature& operator=(const AvailableChannelOrFeature&) = default;
|
|
|
|
bool operator==(const AvailableChannelOrFeature& a) const {
|
|
return (m_kind == a.m_kind) && (m_superIndex == a.m_superIndex) && (m_index == a.m_index) && (m_type == a.m_type) && ((m_kind == 'M') && (m_streamIndex == a.m_streamIndex));
|
|
}
|
|
|
|
QString getId() const { // Eg: "R3:4"
|
|
QString id = QString("%1%2:%3").arg(m_kind).arg(m_superIndex).arg(m_index);
|
|
if (m_kind == 'M') {
|
|
id.append(QString(".%1").arg(m_streamIndex));
|
|
}
|
|
return id;
|
|
}
|
|
|
|
QString getLongId() const { // Eg: "F0:1 StarTracker"
|
|
return QString("%1 %2").arg(getId()).arg(m_type);
|
|
}
|
|
};
|
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
inline uint qHash(const AvailableChannelOrFeature &c, uint seed = 0) noexcept
|
|
{
|
|
return qHash(c.getLongId(), seed);
|
|
}
|
|
#else
|
|
inline size_t qHash(const AvailableChannelOrFeature &c, size_t seed = 0) noexcept
|
|
{
|
|
return qHash(c.getLongId(), seed);
|
|
}
|
|
#endif
|
|
|
|
class SDRBASE_API AvailableChannelOrFeatureList : public QList<AvailableChannelOrFeature>
|
|
{
|
|
public:
|
|
AvailableChannelOrFeatureList() {}
|
|
inline explicit AvailableChannelOrFeatureList(const AvailableChannelOrFeature &i) { append(i); }
|
|
|
|
int indexOfObject(const QObject *object, int from=0) const; //!< // Find index of entry containing specified object. -1 if not found.
|
|
int indexOfId(const QString& longId, int from=0) const; //!< // Find index of entry with specified Id. -1 if not found.
|
|
int indexOfLongId(const QString& longId, int from=0) const; //!< // Find index of entry with specified long Id. -1 if not found.
|
|
};
|
|
|
|
#endif // SDRBASE_AVAILABLECHANNELORFEATURE_H_
|