1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 17:58:43 -05:00
sdrangel/sdrbase/webapi/webapiadapterbase.h

128 lines
4.6 KiB
C
Raw Normal View History

///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
// //
// Swagger server adapter interface //
// //
// 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_WEBAPI_WEBAPIADAPTERBASE_H_
#define SDRBASE_WEBAPI_WEBAPIADAPTERBASE_H_
#include <QMap>
#include "export.h"
#include "SWGPreferences.h"
#include "SWGPreset.h"
2020-09-23 23:38:05 -04:00
#include "SWGFeatureSetPreset.h"
#include "SWGCommand.h"
#include "settings/preferences.h"
#include "settings/preset.h"
2020-09-23 23:38:05 -04:00
#include "settings/featuresetpreset.h"
2019-08-06 02:48:14 -04:00
#include "settings/mainsettings.h"
#include "commands/command.h"
#include "webapiadapterinterface.h"
class PluginManager;
class ChannelWebAPIAdapter;
class DeviceWebAPIAdapter;
/**
* Adapter between API and objects in sdrbase library
*/
class SDRBASE_API WebAPIAdapterBase
{
public:
WebAPIAdapterBase();
~WebAPIAdapterBase();
void setPluginManager(const PluginManager *pluginManager) { m_pluginManager = pluginManager; }
static void webapiFormatPreferences(
SWGSDRangel::SWGPreferences *apiPreferences,
const Preferences& preferences
);
void webapiFormatPreset(
SWGSDRangel::SWGPreset *apiPreset,
const Preset& preset
);
2020-09-23 23:38:05 -04:00
void webapiFormatFeatureSetPreset(
SWGSDRangel::SWGFeatureSetPreset *apiPreset,
const FeatureSetPreset& preset
);
static void webapiFormatCommand(
SWGSDRangel::SWGCommand *apiCommand,
const Command& command
);
2019-08-06 02:48:14 -04:00
static void webapiInitConfig(
MainSettings& mainSettings
);
static void webapiUpdatePreferences(
SWGSDRangel::SWGPreferences *apiPreferences,
const QStringList& preferenceKeys,
2019-08-06 02:48:14 -04:00
Preferences& preferences
);
void webapiUpdatePreset(
bool force,
SWGSDRangel::SWGPreset *apiPreset,
const WebAPIAdapterInterface::PresetKeys& presetKeys,
Preset *preset
);
2020-09-23 23:38:05 -04:00
void webapiUpdateFeatureSetPreset(
bool force,
SWGSDRangel::SWGFeatureSetPreset *apiPreset,
const WebAPIAdapterInterface::FeatureSetPresetKeys& presetKeys,
FeatureSetPreset *preset
);
static void webapiUpdateCommand(
SWGSDRangel::SWGCommand *apiCommand,
const WebAPIAdapterInterface::CommandKeys& commandKeys,
Command& command
);
private:
class WebAPIChannelAdapters
{
public:
ChannelWebAPIAdapter *getChannelWebAPIAdapter(const QString& channelURI, const PluginManager *pluginManager);
void flush();
private:
QMap<QString, ChannelWebAPIAdapter*> m_webAPIChannelAdapters;
};
class WebAPIDeviceAdapters
{
public:
DeviceWebAPIAdapter *getDeviceWebAPIAdapter(const QString& deviceId, const PluginManager *pluginManager);
void flush();
private:
QMap<QString, DeviceWebAPIAdapter*> m_webAPIDeviceAdapters;
};
2020-09-23 23:38:05 -04:00
class WebAPIFeatureAdapters
{
public:
FeatureWebAPIAdapter *getFeatureWebAPIAdapter(const QString& featureURI, const PluginManager *pluginManager);
void flush();
private:
QMap<QString, FeatureWebAPIAdapter*> m_webAPIFeatureAdapters;
};
const PluginManager *m_pluginManager;
WebAPIChannelAdapters m_webAPIChannelAdapters;
WebAPIDeviceAdapters m_webAPIDeviceAdapters;
2020-09-23 23:38:05 -04:00
WebAPIFeatureAdapters m_webAPIFeatureAdapters;
};
2020-09-23 23:38:05 -04:00
#endif // SDRBASE_WEBAPI_WEBAPIADAPTERBASE_H_