Improve settings migration and management (#5107)
[opentx.git] / companion / src / multiprotocols.h
blobbc4c6f71bff1949afd6ea4ee7493f4b5d91f2598
1 /*
2 * Copyright (C) OpenTX
4 * Based on code named
5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #ifndef OPENTX_MULTI_H
22 #define OPENTX_MULTI_H
24 #include <vector>
25 #include <QString>
26 #include <QVector>
27 #include <QStringList>
29 #define MM_RF_CUSTOM_SELECTED 0xff
31 class Multiprotocols
33 public:
35 struct radio_mm_definition {
36 int protocol;
37 QStringList protocols;
38 unsigned int maxSubtype;
39 QString optionsstr;
42 struct MultiProtocolDefinition {
43 const int protocol;
44 const QStringList subTypeStrings;
45 const QString optionsstr;
47 unsigned int numSubytes() const
49 return (unsigned int) subTypeStrings.length();
52 int getOptionMin() const;
54 int getOptionMax() const;
56 MultiProtocolDefinition(const radio_mm_definition &rd) :
57 protocol(rd.protocol),
58 subTypeStrings(rd.protocols),
59 optionsstr(rd.optionsstr)
61 Q_ASSERT(rd.maxSubtype + 1 == (unsigned int) rd.protocols.length());
65 Multiprotocols(std::initializer_list<radio_mm_definition> l)
67 for (radio_mm_definition rd: l)
68 protocols.push_back(MultiProtocolDefinition(rd));
71 const MultiProtocolDefinition &getProtocol(int protocol) const;
73 private:
75 std::vector<MultiProtocolDefinition> protocols;
79 extern const Multiprotocols multiProtocols;
81 #endif //OPENTX_MULTI_H